home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / samba / SMB-info / DOSEXTP.TXT < prev    next >
Encoding:
Text File  |  1994-01-11  |  238.7 KB  |  8,732 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.                      Microsoft Networks
  11.  
  12.             SMB FILE SHARING PROTOCOL EXTENSIONS
  13.  
  14.  
  15.       SMB File Sharing Protocol Extensions Version 2.0
  16.  
  17.  
  18.  
  19.                     Document Version 3.3
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.                       November 7, 1988
  27.  
  28.  
  29.                    Microsoft Corporation
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  65.  
  66.  
  67.  
  68.  
  69.  
  70. SMB Protocol Extensions    - 2 -            November 7, 1988
  71.  
  72.  
  73. 1.  INTRODUCTION
  74.  
  75. This   document    defines    the    extensions    to    the
  76. OpenNET/Microsoft  Networks  File Sharing Protocol (Intel PN
  77. 136329-001) (sometimes referred to as the  "core"  protocol)
  78. that  are  required  to  support Operating Systems richer in
  79. function than MS-DOS 3.x.  The primary goal of these  exten-
  80. sions  is  to allow fully transparent access to remote files
  81. for OS/2 systems using the Microsoft OS/2 LAN Manager.  How-
  82. ever,  they  are not intended to be specific to OS/2.  It is
  83. anticipated that other  Operating  Systems  will  have  many
  84. similar  requirements  and  that they will use the same ser-
  85. vices and protocols to meet them.
  86.  
  87. This extension, when combined with the core protocol, allows
  88. all  file  oriented OS/2 functions to be performed on remote
  89. files using LANMAN 1.0.
  90.  
  91. The extended protocol defined in this document  is  selected
  92. by the dialect string "LANMAN1.0" in the core protocol nego-
  93. tiate request.
  94.  
  95. Acronyms used include:
  96.  
  97.  
  98. VC   - Virtual Circuit.  A transport level connection (some-
  99.      times  called a session) between two networked machines
  100.      (nodes).
  101.  
  102. TID  - Tree Identifier.  A token representing an instance of
  103.      authenticated use of a network resource (often a shared
  104.      subdirectory tree structure).
  105.  
  106. UID  - User Identifier.  A token representing  an  authenti-
  107.      cated user of a network resource.
  108.  
  109. PID  - Process Identifier.  A number which uniquely  identi-
  110.      fies a process on a node.
  111.  
  112. MID  - Multiplex Identifier.  A number which uniquely  iden-
  113.      tifies  a  protocol  request and response within a pro-
  114.      cess.
  115.  
  116. FID  -  File  Identifier.   A  number  which  identifies  an
  117.      instance  of  an open file ( sometimes called file han-
  118.      dle).
  119.  
  120. T.B.D.- To Be Defined.  Further detail will be provided at a
  121.      later time.
  122.  
  123. MBZ  - Must Be Zero.  All reserved fields  must  be  set  to
  124.      zero by the consumer.
  125.  
  126.  
  127.  
  128.  
  129.  
  130. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  131.  
  132.  
  133.  
  134.  
  135.  
  136. SMB Protocol Extensions    - 3 -            November 7, 1988
  137.  
  138.  
  139. 2.  MESSAGE FORMAT
  140.  
  141. All messages sent while using the  extended  protocol  (both
  142. the  core  messages used and the additional messages defined
  143. in this document) will have the following format.
  144.  
  145. BYTE   smb_idf[4];   /* contains 0xFF,'SMB' */
  146. BYTE   smb_com;      /* command code */
  147. BYTE   smb_rcls;     /* error class */
  148. BYTE   smb_reh;      /* reserved for future */
  149. WORD   smb_err;      /* error code */
  150. BYTE   smb_flg;      /* flags */
  151. WORD   smb_res[7];   /* reserved for future */
  152. WORD   smb_tid;      /* authenticated resource identifier */
  153. WORD   smb_pid;      /* caller's process id */
  154. WORD   smb_uid;      /* unauthenticated user id */
  155. WORD   smb_mid;      /* multiplex id */
  156. BYTE   smb_wct;      /* count of 16-bit words that follow */
  157. WORD   smb_vwv[];    /* variable number of 16-bit words */
  158. WORD   smb_bcc;      /* count of bytes that follow */
  159. BYTE   smb_buf[];    /* variable number of bytes */
  160.  
  161.  
  162. The structure defined from smb_idf through  smb_wct  is  the
  163. fixed  portion of the SMB structure sometimes referred to as
  164. the SMB header.  Following the header there  is  a  variable
  165. number  of  words (defined by smb_wct) and following that is
  166. smb_bcc which  defines  an  additional  variable  number  of
  167. bytes.
  168.  
  169.  
  170.         A BYTE is 8 bits.
  171.         A WORD is two BYTEs.
  172.         The BYTEs within a WORD are ordered such that the low BYTE precedes the high
  173.         BYTE.
  174.         A DWORD is two WORDs.
  175.         The WORDs within a DWORD are ordered such that the low WORD precedes the
  176.         high WORD.
  177.  
  178.  
  179. smb_com: - command code.
  180.  
  181. smb_rcls: - error class (see below).
  182.  
  183. smb_ret: - error returned (see below).
  184.  
  185. smb_tid: - Used by the server to identify a resource  (e.g.,
  186.      a disk sub-tree).  (see below)
  187.  
  188. smb_pid: - caller's process id.  Generated by  the  consumer
  189.      (redirector)  to uniquely identify a process within the
  190.      consumer's system.  A response message will always con-
  191.      tain  the same value in smb_pid (and smb_mid) as in the
  192.      corresponding request message.
  193.  
  194.  
  195.  
  196. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  197.  
  198.  
  199.  
  200.  
  201.  
  202. SMB Protocol Extensions    - 4 -            November 7, 1988
  203.  
  204.  
  205. smb_mid: - this field is used for multiplexing multiple mes-
  206.      sages  on  a  single Virtual Circuit (VC) normally when
  207.      multiple requests are from the same  process.  The  PID
  208.      (in smb_pid) and the MID (in smb_mid) uniquely identify
  209.      a request and are used by  the  consumer  to  correlate
  210.      incoming responses to previously sent requests.
  211.  
  212. 3.  NOTES:
  213.  
  214. 1.   smb_flg can have the following values:
  215.  
  216. bit0 - When set (returned) from the server in the  Negotiate
  217.      response  protocol,  this bit indicates that the server
  218.      supports the "sub dialect" consisting  of  the  Lockan-
  219.      dRead  and  WriteandUnlock  protocols  defined later in
  220.      this document.
  221.  
  222.  
  223. bit1 - When on (on a protocol  request  being  sent  to  the
  224.      server),  the  consumer  guarantees  that  there  is  a
  225.      receive buffer posted such that a "Send.No.Ack" can  be
  226.      used  by  the  server  to  respond  to  the  consumer's
  227.      request.  The LANMAN 1.0 Redirector for OS/2  will  not
  228.      set this bit.
  229.  
  230.  
  231. bit2 - Reserved (must be zero).
  232.  
  233.  
  234.  
  235. bit3 - When on,  all  pathnames  in  the  protocol  must  be
  236.      treated  as caseless.  When off, the pathnames are case
  237.      sensitive.  This allows forwarding of the protocol mes-
  238.      sage  on various extended VCs where caseless may not be
  239.      the norm.  The LANMAN  1.0  Redirector  for  OS/2  will
  240.      always have this bit on to indicate caseless pathnames.
  241.  
  242.  
  243. bit4 - When on (on the Session Setup and X protocol  defined
  244.      later  in  this document), all paths sent to the server
  245.      by the consumer are already in the canonicalized format
  246.      used by OS/2.  This means that file/directory names are
  247.      in upper case, are valid characters and backslashes are
  248.      used as seperators.
  249.  
  250.  
  251. bit5 - When on (on core  protocols  Open,  Create  and  Make
  252.      New),  this  indicates  that the consumer is requesting
  253.      that the file be "opportunisticly" locked if this  pro-
  254.      cess is the only process which has the file open at the
  255.      time of the open request.  If the server "grants"  this
  256.      oplock  request, then this bit should remain set in the
  257.      coresponding response protocol to indicate to the  con-
  258.      sumer  that  the  oplock  request  was granted. See the
  259.  
  260.  
  261.  
  262. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  263.  
  264.  
  265.  
  266.  
  267.  
  268. SMB Protocol Extensions    - 5 -            November 7, 1988
  269.  
  270.  
  271.      discussion of "oplock" in  the  sections  defining  the
  272.      "Open  and  X"  and  "Locking and X" protocols later in
  273.      this document (this bit has the same function as bit  1
  274.      of smb_flags of the "Open and X" protocol).
  275.  
  276.  
  277. bit6 - When on (on core  protocols  Open,  Create  and  Make
  278.      New),  this indicates that the server should notify the
  279.      consumer on  any  action  which  can  modify  the  file
  280.      (delete,  setattrib,  rename,  etc.).   If not set, the
  281.      server need only notify the consumer  on  another  open
  282.      request.   See  the  discussion of "oplock" in the sec-
  283.      tions defining the "Open and X"  and  "Locking  and  X"
  284.      protocols later in this document (this bit has the same
  285.      function as bit 2 of smb_flags of the "Open and X" pro-
  286.      tocol).  Bit6 only has meaning if bit5 is set.
  287.  
  288.  
  289. bit7 - When on, this protocol is being sent from the  server
  290.      in  response  to  a consumer request. The smb_com (com-
  291.      mand) field usually contains the same value in a proto-
  292.      col  request  from the consumer to the server as in the
  293.      matching response from  the  server  to  the  consumer.
  294.      This   bit   unambiguously  distinguishes  the  command
  295.      request from the command response.  On a multiplexed VC
  296.      on  a  node  where both server and consumer are active,
  297.      this bit can be used by the node's SMB delivery  system
  298.      to help identify whether this protocol should be routed
  299.      to a waiting consumer process or to the server.
  300.  
  301.  
  302.  
  303. 2.   smb_uid is the user identifier.  It is used by the LAN-
  304.      MAN  1.0 extended protocol when the server is executing
  305.      in "user level security mode"  to  validate  access  on
  306.      protocols  which  reference  symbolicly named resources
  307.      (such as file open).  Thus  differing  users  accessing
  308.      the  same  TID  may  be granted differing access to the
  309.      resources defined by the TID based on smb_uid. The  UID
  310.      requested  is  validated  by the server via the Session
  311.      Set Up protocol.
  312.  
  313.      Note that -2 is reserved as an invalid UID.
  314.  
  315. 4.   In the LANMAN 1.0 extended protocol environment the TID
  316.      represents  an instance of an authenticated use.   This
  317.      is the result of a successful NET USE to a server using
  318.      a valid netname and password (if any).
  319.  
  320.      If the server is executing in a "share  level  security
  321.      mode",  the  tid is the only thing used to allow access
  322.      to the shared resource.  Thus if the user  is  able  to
  323.      perform  a  successful NET USE to the server specifying
  324.      the  appropriate  netname  and  passwd  (if  any)   the
  325.  
  326.  
  327.  
  328. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  329.  
  330.  
  331.  
  332.  
  333.  
  334. SMB Protocol Extensions    - 6 -            November 7, 1988
  335.  
  336.  
  337.      resource may be accessed according to the access rights
  338.      associated with the shared resource (same for  all  who
  339.      gained access this way).
  340.  
  341.      If however the server is executing in "user level secu-
  342.      rity  mode", access to the resource is based on the UID
  343.      (validated on the Session Set UP protocol) and the  TID
  344.      is NOT associated with access control but rather merely
  345.      defines the resource  (such  as  the  shared  directory
  346.      tree).
  347.  
  348.      In most SMB protocols, smb_tid  must  contain  a  valid
  349.      TID.   Exceptions  include prior to getting a TID esta-
  350.      blished    including    NEGOTIATE,    TREE     CONNECT,
  351.      SESS_SETUPandX   and  TREE_CONNandX  protocols.   Other
  352.      exceptions include QUERY_SRV_INFO  some  forms  of  the
  353.      TRANSACTION  protocol  and ECHO.  A NULL TID is defined
  354.      as 0xFFFF. The server is responsible for enforcing  use
  355.      of a valid TID where appropriate.
  356.  
  357.  
  358. 5.   As in the core, smb_pid uniquely identifies a  consumer
  359.      process.  Consumers inform servers of the creation of a
  360.      new process by simply introducing a new  smb_pid  value
  361.      into the dialogue (for new processes).
  362.  
  363.      In the core protocol however, the "Process Exit" proto-
  364.      col  was  used to indicate the catastrophic termination
  365.      of a process (or session).  In the single  tasking  DOS
  366.      system,  it was possible for hard errors to occur caus-
  367.      ing the destruction of the process with files remaining
  368.      open.   Thus  a Process Exit protocol was used for this
  369.      occurrence to allow  the  server  to  close  all  files
  370.      opened by that process.
  371.  
  372.      In the LANMAN 1.0 extended protocol, no "Process  Exit"
  373.      protocol  will  be  sent.   The  operating  system will
  374.      ensure that the "close Protocol" will be sent when  the
  375.      last  process referencing the file closes it.  From the
  376.      server's point of view, there is  no  concept  of  FIDs
  377.      "belonging to" processes.  A FID returned by the server
  378.      to one process may be used by any other  process  using
  379.      the  same  VC and TID. There is no "birth announcement"
  380.      (no "fork" protocol) sent to the server.  It is  up  to
  381.      the consumer to ensure only valid processes gain access
  382.      to FIDs (and TIDs).  On TREE DISCONNECT (or when the VC
  383.      environment  is  terminated)  the server may invalidate
  384.      any files opened by any process within the VC  environ-
  385.      ment using that TID.
  386.  
  387.  
  388. 6.   Systems using the LANMAN  1.0  extended  protocol  will
  389.      typically be multi-tasked and will allow multiple asyn-
  390.      chronous input/output requests per task.   Therefore  a
  391.  
  392.  
  393.  
  394. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  395.  
  396.  
  397.  
  398.  
  399.  
  400. SMB Protocol Extensions    - 7 -            November 7, 1988
  401.  
  402.  
  403.      multiplex  ID (smb_mid) is used (along with smb_pid) to
  404.      allow multiplexing the single consumer/server VC  among
  405.      the consumer's multiple processes, threads and requests
  406.      per thread.
  407.  
  408.      The consumer is responsible  for  ensuring  that  every
  409.      request  includes  a  value  in the smb_mid field which
  410.      will allow the  response  to  be  associated  with  the
  411.      correct  request (at least the smb_pid and smb_mid must
  412.      uniquely  identify  the  request/response  relationship
  413.      system wide).
  414.  
  415.      The server  is  responsible  for  ensuring  that  every
  416.      response  contains  the same smb_mid value (and smb_pid
  417.      value) as its request.  The consumer may then  use  the
  418.      smb_mid  value (along with smb_pid value) for associat-
  419.      ing requests and responses and may have up to the nego-
  420.      tiated  number of requests outstanding at any time on a
  421.      multiplexed file server VC.
  422.  
  423.  
  424. 7.   The LANMAN 1.0 extended protocol enhances the semantics
  425.      of the pathname.
  426.  
  427.      Two special pathname component values -- "."  and  ".."
  428.      --  must be recognized.  There may be multiple of these
  429.      components in a path  name.   They  have  the  standard
  430.      meanings  --  "."  points  to  its  own directory, ".."
  431.      points to its directory's parent.
  432.  
  433.      Note that it is the server's responsibility  to  ensure
  434.      that  the  ".."  can  not  be  used  to  gain access to
  435.      files/directories above the "virtual root"  as  defined
  436.      by the Tree Connect (TID).
  437.  
  438.  
  439. 8.   The new  LANMAN  1.0  extended  protocol  requests  and
  440.      responses  are variable length (as was true in "core").
  441.      Thus additional words may be  added  in  the  smb_vwv[]
  442.      area  in  the  future as well as additional bytes added
  443.      within the smb_buf[] area.  Servers must be implemented
  444.      such  that  additional  fields in either of these areas
  445.      will not cause the  command  to  fail.   If  additional
  446.      fields  are encountered which are not recognized by the
  447.      server's level of SMB implementation,  they  should  be
  448.      ignored. This allows for future upgrade of the protocol
  449.      and eliminates the need for "reserved fields".
  450.  
  451.  
  452. 9.   The contents of response parameters is  not  guaranteed
  453.      in  the  case of an error return (any protocol response
  454.      with an error set in the SMB header may have smb_wct of
  455.      zero and smb_bcc count of zero).
  456.  
  457.  
  458.  
  459.  
  460. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  461.  
  462.  
  463.  
  464.  
  465.  
  466. SMB Protocol Extensions    - 8 -            November 7, 1988
  467.  
  468.  
  469. 10.  When LANMAN 1.0 extended protocol has been  negotiated,
  470.      the ERRDOS error class has been expanded to include all
  471.      errors which may be generated  by  the  OS/2  operating
  472.      system.   As  such,  the  error code values defined for
  473.      error class ERRDOS in this document are a subset of the
  474.      possible  error  values.  See the OS/2 operating system
  475.      documentation for the complete  set  of  possible  OS/2
  476.      (ERRDOS) error codes.
  477.  
  478.  
  479.  
  480. These semantic changes apply to all "core" requests used  by
  481. the  extended protocol.  Where there are additional changes,
  482. they are documented with the new requests.  The server  hav-
  483. ing  negotiated  LANMAN 1.0 is expected to still support all
  484. core protocol requests.
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  527.  
  528.  
  529.  
  530.  
  531.  
  532. SMB Protocol Extensions    - 9 -            November 7, 1988
  533.  
  534.  
  535. The following are the  core  protocol  requests  which  must
  536. still  be  supported  in  the  LANMAN  1.0 extended protocol
  537. without change.  See  "File  Sharing  Protocol"  Intel  Part
  538. number  136329-001 for detailed explanation of each protocol
  539. request/response.
  540.  
  541.         TREE CONNECT
  542.         TREE DISCONNECT
  543.         OPEN FILE
  544.         CREATE FILE
  545.         CLOSE FILE
  546.         FLUSH FILE
  547.         READ
  548.         WRITE
  549.         SEEK
  550.         CREATE DIRECTORY
  551.         DELETE DIRECTORY
  552.         DELETE FILE
  553.         RENAME FILE
  554.         GET FILE ATTRIBUTES
  555.         SET FILE ATTRIBUTES
  556.         LOCK RECORD
  557.         UNLOCK RECORD
  558.         CREATE TEMPORARY FILE (no longer used by LANMAN 1.0 Redirector)
  559.         PROCESS EXIT          (no longer used by LANMAN 1.0 Redirector)
  560.         MAKE NEW FILE
  561.         CHECK PATH
  562.         GET SERVER ATTRIBUTES
  563.         NEGOTIATE PROTOCOL (additional fields in response if LANMAN 1.0 negotiated)
  564.         FILE SEARCH
  565.         CREATE PRINT FILE
  566.         CLOSE PRINT FILE
  567.         WRITE PRINT FILE
  568.         (core Message Commands are also supported)
  569.  
  570. Support of all core requests within the LANMAN 1.0  extended
  571. protocol is mandatory.  However, the following core requests
  572. will no longer be generated by the  OS/2  implementation  of
  573. the  redirector  when  LANMAN 1.0 extended protocol has been
  574. negotiated.
  575.  
  576.         PROCESS EXIT
  577.         CREATE TEMPORARY FILE
  578.         CREATE PRINT FILE
  579.         CLOSE PRINT FILE
  580.         WRITE PRINT FILE
  581.  
  582. The only protocol format change to a core  protocol  service
  583. is  that  the  response to the negotiate protocol (NEGOTIATE
  584. PROTOCOL) will contain additional fields  if  the  LANMAN1.0
  585. string  has  been  selected  by  the server thus effectively
  586. placing the session into LANMAN 1.0 extended protocol.   The
  587. additional  fields  returned  will  be  documented in detail
  588. later in this document.
  589.  
  590.  
  591.  
  592. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  593.  
  594.  
  595.  
  596.  
  597.  
  598. SMB Protocol Extensions    - 10 -           November 7, 1988
  599.  
  600.  
  601. All other protocol requests within the LANMAN  1.0  extended
  602. protocol  have  a  new  command value from that of a similar
  603. function in core protocol.  Thus the server  need  not  con-
  604. stantly  test the protocol version negotiated.  The consumer
  605. is expected to only submit appropriate requests  within  the
  606. dialect negotiated.
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  659.  
  660.  
  661.  
  662.  
  663.  
  664. SMB Protocol Extensions    - 11 -           November 7, 1988
  665.  
  666.  
  667. The following are  the  new  LANMAN  1.0  extended  protocol
  668. requests, each will be defined in detail later in this docu-
  669. ment.
  670.  
  671.  
  672.         SESS_SETUPandX    (X is another valid protocol request e.g. TREE_CONNandX)
  673.         TREE_CONNandX     (X is another valid protocol request e.g. OPEN)
  674.         OPENandX          (X is another valid protocol request e.g. READ)
  675.         READandX          (X is another valid protocol request e.g. CLOSE)
  676.         WRITEandX         (X is another valid protocol request e.g. READ)
  677.         FIND              (matches OS/2 form of FILE SEARCH)
  678.         FIND_UNIQUE       (matches OS/2 form of FILE SEARCH)
  679.         FIND_CLOSE        (matches OS/2 form of FILE SEARCH)
  680.         READ_BLOCK_RAW    (read larger than negotiated buffer size request raw)
  681.         READ_BLOCK_MPX    (read larger than negotiated buffer size request multiplexed)
  682.         WRITE_BLOCK_RAW   (write larger than negotiated buffer size request raw)
  683.         WRITE_BLOCK_MPX   (write larger than negotiated buffer size request multiplexed)
  684.         GET_E_FILE_ATTR   (accommodate new OS/2 system call)
  685.         SET_E_FILE_ATTR   (accommodate new OS/2 system call)
  686.         LOCKINGandX       (accommodate new OS/2 system call)
  687.         COPY_FILE         (used when both source and target are remote)
  688.         MOVE_FILE         (used when both source and target are remote)
  689.         IOCTL             (pass IOCTL request on to server and retrieve results)
  690.         TRANSACTION       (allows bytes in/out associated with name)
  691.         ECHO              (echo sent data back)
  692.         WRITEandCLOSE     (write final bytes then close file)
  693.         LOCKandREAD       (Lock bytes then Read locked bytes)
  694.         WRITEandUnlock    (Write bytes then Unlock bytes)
  695.  
  696.  
  697.  
  698. On every new command ending in "and_X" above, the  following
  699. rules apply:
  700.  
  701.  
  702. o    The embedded command does not  repeat  the  SMB  header
  703.      information.  Rather it starts at the smb_wct field.
  704.  
  705.  
  706. o    All multiple (chained) requests  must  fit  within  the
  707.      negotiated    transmit    size.     For   example,   if
  708.      TREE_CONNandX included OPENandX  which  included  WRITE
  709.      were  sent, they would all have to fit within the nego-
  710.      tiated buffer size.  This would limit the size  of  the
  711.      write.
  712.  
  713.  
  714. o    There is one (negotiated buffer size max) message  sent
  715.      containing the chained requests and there is one (nego-
  716.      tiated buffer size max) response message to the chained
  717.      requests.   The  server  may NOT elect to send separate
  718.      responses to each of the chained requests.
  719.  
  720.  
  721.  
  722.  
  723.  
  724. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  725.  
  726.  
  727.  
  728.  
  729.  
  730. SMB Protocol Extensions    - 12 -           November 7, 1988
  731.  
  732.  
  733. o    All multiple (chained) responses must  fit  within  the
  734.      negotiated  transmit  size.   This  limits  the maximum
  735.      value on an embedded  READ  for  example.   It  is  the
  736.      consumer's  responsibility  to  not  request more bytes
  737.      than will fit within the multiple response.
  738.  
  739.  
  740. o    The server will implicitly use the result of the  first
  741.      command  in  the  "X"  command.   For  example  the TID
  742.      obtained via TCONandX would be  used  in  the  embedded
  743.      OPENandX  and the FID obtained in the OPENandX would be
  744.      used in the embedded READ.
  745.  
  746.  
  747. o    If multiple (chained) requests  reference  a  FID,  the
  748.      smb_fid  field  must contain the same FID value in each
  749.      request.  In other words, each request can only  refer-
  750.      ence  the  same  FID (and TID) as the other commands in
  751.      the combined request.   The  chained  requests  can  be
  752.      thought  of  as performing a single (multi-part) opera-
  753.      tion on the same resource.  This  simplifies  the  han-
  754.      dling by the worker process on the server node.
  755.  
  756.  
  757. o    The first function (command) to encounter an error will
  758.      stop  all  further processing of embedded commands. The
  759.      server will NOT back out commands that succeeded.  Thus
  760.      if  and  OPENandRead was being performed and the server
  761.      was able to open the file  successfully  but  the  read
  762.      encountered an error, the file would remain open.  This
  763.      is exactly the same as if the requests  had  been  sent
  764.      separately.
  765.  
  766.  
  767. o    If an error occurs while processing  chained  requests,
  768.      the  last  response  (of  the  chained responses in the
  769.      buffer) will be the one which  encountered  the  error.
  770.      Other  unprocessed  chained  requests  will  have  been
  771.      ignored when the server encountered the error and  will
  772.      not  be  represented in the chained response.  Actually
  773.      the last valid smb_com2 (if  any)  will  represent  the
  774.      protocol  on  which  the  error  occurred.  If no valid
  775.      smb_com2 is present, then the  error  occurred  on  the
  776.      first request/response and smb_com contains the command
  777.      which failed.  In all cases the error class and code is
  778.      returned  in the smb_rcls and smb_err fields of the SMB
  779.      header at the start of the response buffer.
  780.  
  781.  
  782. o    Each chained request and response contains  the  offset
  783.      (from  the start of the SMB header) to the next chained
  784.      request/response (in the field smb_off2 in the  various
  785.      "and X" protocols defined later e.g. Open and X).  This
  786.      allows building the requests  unpacked.  There  may  be
  787.  
  788.  
  789.  
  790. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  791.  
  792.  
  793.  
  794.  
  795.  
  796. SMB Protocol Extensions    - 13 -           November 7, 1988
  797.  
  798.  
  799.      space  between  the  end  of  the  previous request (as
  800.      defined by smb_wct and smb_bcc) and the  start  of  the
  801.      next  chained request.  This simplifies the building of
  802.      chained protocol requests.  Note that because the  con-
  803.      sumer  must know the size of the data being returned in
  804.      order to post the  correct  number  of  receives  (e.g.
  805.      Transaction, Read Block MPX), the data in each response
  806.      protocol is expected to be  truncated  to  the  maximum
  807.      number  of  512  byte  blocks  (sectors) which will fit
  808.      (starting at a DWORD boundary) in the negotiated buffer
  809.      size with the odd bytes remaining (if any) in the final
  810.      buffer.
  811.  
  812.  
  813. 4.  ARCHITECTURAL MODEL
  814.  
  815. The Network File Access system described  in  this  document
  816. deals  with two types of systems on the network -- consumers
  817. and servers.  A consumer is a system that  requests  network
  818. file  services  (commonly  referred  to as the redirector in
  819. DOS) and a server is a system  that  delivers  network  file
  820. services.  Consumers and servers are logical systems; a con-
  821. sumer and server may coexist in a single physical system.
  822.  
  823. Consumers are responsible for directing  their  requests  to
  824. the appropriate server.  The network addressing mechanism or
  825. naming convention through which the server is identified  is
  826. outside the scope of this document.
  827.  
  828. Each server makes available to the network a  self-contained
  829. file  structure  (or  other  resource).   The resource being
  830. shared may be a directory tree, spooled device, I/O  device,
  831. named pipe, etc..  There are no storage or service dependen-
  832. cies on any other servers.  A file (or other resource)  must
  833. be entirely contained by a single server.
  834.  
  835. The LANMAN 1.0 extended (like the core) file sharing  proto-
  836. col  requires  server  authentication  of  users before file
  837. accesses are allowed.  Each server  processor  authenticates
  838. its own users.
  839.  
  840. This authentication model  assumes  that  the  LAN  connects
  841. autonomous  systems  that are willing to make some subset of
  842. their local files (or other resource)  available  to  remote
  843. users.
  844.  
  845. The LANMAN 1.0 extended protocol however defines two methods
  846. which can be selected by the server for security.
  847.  
  848. A "share level security mode" server makes some directory on
  849. a  disk device (or other resource) sharable (accessible from
  850. any consumer on the network).  An optional password  may  be
  851. required  to  gain access.  Thus any user on the network who
  852. knows the name of the server, the name  ("netname")  of  the
  853.  
  854.  
  855.  
  856. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  857.  
  858.  
  859.  
  860.  
  861.  
  862. SMB Protocol Extensions    - 14 -           November 7, 1988
  863.  
  864.  
  865. resource  and  the  password (if any) has full access to all
  866. files and directories under the shared "tree" ("full" access
  867. as defined by the access level specified for the share).
  868.  
  869. A "user level security mode" server also makes  some  direc-
  870. tory  on  a  disk device (or other resource) sharable but in
  871. addition requires the user to provide an account (user) name
  872. (and  optional  account  (user)  password)  in order to gain
  873. access.  The consumer also supplies the UID value it  wishes
  874. to  represent this user (see Session Set Up protocol defini-
  875. tion).
  876.  
  877. Thus the server is now able to allow differing access rights
  878. depending   on  the  validated  UID  (in  smb_uid)  on  each
  879. resource.  One account may have full  access,  another  read
  880. only  and  perhaps  another no access to differing files and
  881. directories within the shared  "tree".   Access  implementa-
  882. tions  are  server  dependent  and outside the scope of this
  883. document, however user level security mode allows validating
  884. access  based  on account-name (and password) access control
  885. lists associated with each resource.
  886.  
  887. The server is expected to be in either "user level  security
  888. mode"  or  "share level security mode" (not in some combina-
  889. tion).  The security mode of the server is returned  in  the
  890. response  on  the  negotiate  command if LANMAN 1.0 extended
  891. dialect is selected by the server. This allows the  consumer
  892. to easily select the appropriate protocols to be used.
  893.  
  894.  
  895. The following environments exist in the LANMAN 1.0  extended
  896. file sharing protocol environment.
  897.  
  898.  
  899. a)   Virtual Circuit Environment.  This consists of  one  or
  900.      more  VC(s)  established  between a consumer system and
  901.      server system.  Thus it is the logical session  between
  902.      the  server node and consumer node which is implemented
  903.      with the use of one or more Virtual Circuits.  Each  of
  904.      these VC(s) may be a multiplex VC in that any number of
  905.      tasks and any number of requests may be active  on  the
  906.      VC at the same time.
  907.  
  908.      Additional VC(s) are used primarily to support optional
  909.      LANMAN  1.0  extended  protocols which allow rapid data
  910.      movement if only one process is active on the VC.  Con-
  911.      sumers  using additional VC(s) would normally have only
  912.      a single request active on the VC at any time, in order
  913.      to receive data directly into user space for example.
  914.  
  915.      Additional VC(s) when used are to be considered a logi-
  916.      cal  extension  of  the first VC.  A smb_tid field in a
  917.      protocol received on an additional VC should be authen-
  918.      ticated to the one established on the first VC, etc..
  919.  
  920.  
  921.  
  922. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  923.  
  924.  
  925.  
  926.  
  927.  
  928. SMB Protocol Extensions    - 15 -           November 7, 1988
  929.  
  930.  
  931.      All of the VCs are the same as far  as  the  server  is
  932.      concerned.   Support  for  more than one VC between the
  933.      consumer and server is optional.  If more than  one  VC
  934.      is  in  use,  the server must ensure that all responses
  935.      are sent on the same VC which received the request.
  936.  
  937.      A VC is formed using transport services.
  938.  
  939.  
  940. b)   Resource Environment.  As in the core protocol, this is
  941.      represented  by a Tree ID (TID). A TID uniquely identi-
  942.      fies a resource sharing connection between  a  consumer
  943.      and  server.  The resource being shared may be a direc-
  944.      tory tree, spooled  device,  I/O  device,  named  pipe,
  945.      etc..
  946.  
  947.      In a server executing in "share  level  security  mode"
  948.      (and  also  in  servers  which  do  not  support  these
  949.      extended protocols), the TID also identifies the  scope
  950.      and type of accesses allowed across the connection.
  951.  
  952.      In most SMB protocols, smb_tid  must  contain  a  valid
  953.      TID.   Exceptions  include prior to getting a TID esta-
  954.      blished    including    NEGOTIATE,    TREE     CONNECT,
  955.      SESS_SETUPandX   and  TREE_CONNandX  protocols.   Other
  956.      exceptions include QUERY_SRV_INFO  some  forms  of  the
  957.      TRANSACTION  protocol  and ECHO.  A NULL TID is defined
  958.      as 0xFFFF. The server is responsible for enforcing  use
  959.      of a valid TID where appropriate.
  960.  
  961.      There may be any number of resource sharing connections
  962.      (TIDs) per VC set.
  963.  
  964.  
  965. c)   User Environment.  This is represented  by  a  User  ID
  966.      (UID).   A  UID in (smb_uid) uniquely identifies a user
  967.      within a given VC environment. A server  (executing  in
  968.      "user  level  security mode") uses this to identify the
  969.      scope and type of access allowed this user.
  970.  
  971.  
  972. c)   Process Environment.  This is represented by a  process
  973.      ID (PID).  A PID uniquely identifies a consumer process
  974.      (thread) within  a  given  VC  environment.   From  the
  975.      server's  point  of  view,  a new process (new value in
  976.      smb_pid) may be introduced at any time.   There  is  no
  977.      "fork" protocol and files opened by another process may
  978.      be  manipulated  by  the  new  process  (provided   the
  979.      appropriate smb_tid is supplied).
  980.  
  981.  
  982. d)   File Environment.  This is represented by a File Handle
  983.      (FID).   A  FID  identifies  an open file and is unique
  984.      within a given VC environment (same File  Handle  (FID)
  985.  
  986.  
  987.  
  988. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  989.  
  990.  
  991.  
  992.  
  993.  
  994. SMB Protocol Extensions    - 16 -           November 7, 1988
  995.  
  996.  
  997.      may  be  used in additional VC(s)).  Note that the File
  998.      Handle (FID) is logon environment  wide  in  scope.   A
  999.      file  may  be  opened  and its Handle passed to another
  1000.      process for use without being opened by  that  process.
  1001.      The  smb_tid  field must contain the same value as that
  1002.      used when the file was opened.
  1003.  
  1004. If a VC environment (all VC(s)) is terminated all PIDs, TIDs
  1005. and  FIDs  within it will be invalidated.  Note - additional
  1006. VC(s) may be terminated without terminating the "VC environ-
  1007. ment".
  1008.  
  1009. If a Resource Environment is terminated (TID invalidated via
  1010. Tree  Disconnect  protocol) all PIDS and FIDs within it will
  1011. be invalidated.
  1012.  
  1013.  
  1014. 4.1.  Process Management
  1015.  
  1016. How and when servers create and  destroy  processes  is,  of
  1017. course,  an implementation issue and there is no requirement
  1018. that this be tied in  any  way  to  the  consumer's  process
  1019. management.
  1020.  
  1021. Because a file handle may be obtained by one  consumer  pro-
  1022. cess and passed to another (e.g. child) process for use, the
  1023. server can not release resources such as locks  or  FIDs  on
  1024. process exit (Note that process exit is no longer sent).
  1025.  
  1026. Rather the server must wait until the lock is removed or the
  1027. file  closed  by  the  consumer.   Consumer  implementations
  1028. should close handles and free locks as soon as  possible  to
  1029. prevent server resource problems.
  1030.  
  1031. When the server receives a  tree  disconnect  protocol,  all
  1032. processes,  locks,  FIDs, etc. created on behalf of that TID
  1033. (logon environment) may be freed.
  1034.  
  1035. If the VC aborts (VC environment  is  terminated)  then  all
  1036. resources for the consuming node may be freed.
  1037.  
  1038. All messages, except Negotiate, include a process  ID  (PID)
  1039. to  indicate which user process initiated a request.  Consu-
  1040. mers inform servers of the creation of a new process by sim-
  1041. ply  introducing  a  new  PID into the dialogue. There is no
  1042. "fork" protocol to indicate to the server any  parent  child
  1043. process  relationship.   This is not needed because any pro-
  1044. cess may use handles created by another process (there is no
  1045. special  privilege  or  relationship to the parent process).
  1046. Thus most server implementations will not need the PID, how-
  1047. ever,  the  PID  value  in  smb_pid  must be returned in the
  1048. response (along with smb_mid) for the use of the  consumer's
  1049. "SMB delivery system".
  1050.  
  1051.  
  1052.  
  1053.  
  1054. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. SMB Protocol Extensions    - 17 -           November 7, 1988
  1061.  
  1062.  
  1063. In the LANMAN 1.0 extended protocol, no "Process Exit"  pro-
  1064. tocol  will  be sent.  The operating system will ensure that
  1065. the "close Protocol" will be  sent  when  the  last  process
  1066. referencing  a file closes it.  Note that a close implicitly
  1067. frees locks which may be present on the  file  (those  locks
  1068. placed on the file using the file handle being closed).
  1069.  
  1070. 5.  File Sharing Connections
  1071.  
  1072. The networks using this file sharing protocol  will  contain
  1073. not only multi-user systems with user based security models,
  1074. but single-user systems that have no concept of user-ids  or
  1075. permissions.  Once these nodes are connected to the network,
  1076. however, they are in a multi-user  environment  and  need  a
  1077. method  of access control.  First, unsecure nodes need to be
  1078. able to provide some sort of bona-fides to other  net  nodes
  1079. which  do  have permissions, secondly unsecure nodes need to
  1080. control access to their resources by others.
  1081.  
  1082. This protocol defines a mechanism that enables  the  network
  1083. software  to  provide  the security where it is missing from
  1084. the operating system, and supports user based security where
  1085. it  is  provided by the operating system. The mechanism also
  1086. allows nodes with  no  concept  of  user-id  to  demonstrate
  1087. access  authorization  to  nodes  which do have a permission
  1088. mechanism.  Finally, the permission protocol is designed  so
  1089. that  it can be omitted if both nodes share a common permis-
  1090. sion mechanism.
  1091.  
  1092. This protocol, called the "tree connect" protocol, does  not
  1093. specify a user interface.  A possible user interface will be
  1094. described by way of illustration.
  1095.  
  1096. 5.1.  Share Level Security Mode Server Nodes
  1097.  
  1098. The following examples apply to access  to  serving  systems
  1099. which do NOT have a user based permission mechanism.
  1100.  
  1101. a) NET SHARE
  1102.  
  1103. By default all network requests are refused as unauthorized.
  1104. Should  a  user  wish  to allow access to some or all of his
  1105. files he offers access to an arbitrary set  of  subtrees  by
  1106. specifying each subtree and an optional password.
  1107.  
  1108.         Examples:
  1109.  
  1110.         NET SHARE  src=c:\dir1\src  "bonzo"
  1111.  
  1112.      assign password "bonzo" to all files  within  directory
  1113.      "dir1\src" and its subdirectories with the "short name"
  1114.      src being the name used to connect to this offer.
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. SMB Protocol Extensions    - 18 -           November 7, 1988
  1127.  
  1128.  
  1129.  
  1130.         NET SHARE  c=c:\        " "      RO
  1131.  
  1132.         NET SHARE  work=c:\work  "flipper"  RW
  1133.  
  1134.      offer read-only access to  everything  (all  files  are
  1135.      within  the root directory or its subdirectories) Offer
  1136.      read-write access to all files within the \work  direc-
  1137.      tory and its subdirectories.
  1138. b) NET USE
  1139.  
  1140. Other users can gain access to one or more offered  subtrees
  1141. via the NET USE command.  Once the NET USE command is issued
  1142. the user can access the files freely without further special
  1143. requirements.
  1144.  
  1145.         Examples:
  1146.  
  1147.         1. NET USE  d: \\Server1\src  "bonzo"
  1148.  
  1149.  
  1150.      This gains full access to the files and directories  on
  1151.      Server1 matching the offer defined by the netname "src"
  1152.      with the password of "bonzo".  The user may now address
  1153.      files  on  Server1  c:\dir1\src by referencing d:. E.g.
  1154.      "type d:srcfile1.c".
  1155.  
  1156.         2. NET USE  e: \\Server1\c
  1157.  
  1158.         3. NET USE  f: \\Server1\work  "flipper"
  1159.  
  1160.      Now any read request to any file on that node (drive c)
  1161.      is   valid  (e.g.  "type  e:\bin\foo.bat").  Read-write
  1162.      requests only succeed to files  whose  pathnames  start
  1163.      with  f:  (e.g.  "copy  foo  f:foo.tmp"  copies  foo to
  1164.      Server1 c:\work\foo.tmp).
  1165. The consumer system must remember the drive identifier  sup-
  1166. plied with the NET USE request and associate it with the TID
  1167. value returned by the  server.   Subsequent  requests  using
  1168. this TID must include only the pathname relative to the con-
  1169. nected subtree as the server treats the subtree as the  root
  1170. directory (virtual root).
  1171.  
  1172. When the user references one of the remote drives, the  con-
  1173. sumer  looks  through  its  list of drives for that node and
  1174. includes the TID associated with this drive in  the  smb_tid
  1175. field of each request.
  1176.  
  1177. Note that one offers (shares)  a  directory  and  all  files
  1178. underneath  that directory are then affected.  If a particu-
  1179. lar file is within the range of multiple offer ranges,  con-
  1180. necting  to any of the offer ranges gains access to the file
  1181. with the permissions specified for the offer  named  in  the
  1182. NET  USE.   The server will not check for nested directories
  1183.  
  1184.  
  1185.  
  1186. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. SMB Protocol Extensions    - 19 -           November 7, 1988
  1193.  
  1194.  
  1195. with more restrictive permissions.
  1196.  
  1197. 5.2.  User Level Security Mode Server Nodes
  1198.  
  1199. Servers with user based file security (in "user level  secu-
  1200. rity  mode")  will  require  that  the  consumer  present an
  1201. account name and account passwd  (if  any)  along  with  the
  1202. requested  UID value (via the Session Set Up protocol) prior
  1203. to accessing resources.
  1204.  
  1205. When the Session Set Up request is  received,  the  account-
  1206. name  is  validated  and the UID representing that authenti-
  1207. cated instance of the user is validated.  This UID  must  be
  1208. included in all further requests made on behalf of the user.
  1209.  
  1210. The Tree Connect protocol is still used to define the direc-
  1211. tory (tree) or other resource available to the user.
  1212.  
  1213. The server in user level security mode uses the UID to allow
  1214. differing  types  of  access  to  the same resources under a
  1215. given TID.
  1216.  
  1217. Note that a single consumer user  may  issue  multiple  Tree
  1218. Connect  commands in order to gain access to multiple shared
  1219. resources. Multiple Session Set  Up  commands  may  also  be
  1220. issued  in  order  to validate additional users.  NOTE - The
  1221. first release of LANMAN 1.0 will allow only one  valid  user
  1222. at  a  time.  A user established by a Session Set Up command
  1223. may be logged off via the User Logoff and X  command  (after
  1224. all  files  and  other  resources in use are closed) and the
  1225. Session Set Up  and  X  command  used  to  validate  another
  1226. userid.
  1227.  
  1228. The permission-based (user level security mode) systems  may
  1229. execute  a  NET SHARE command which shares the entire system
  1230. and set up name/password (or whatever)  information  in  its
  1231. user  definition  files  in  order to allow user/group based
  1232. access to the shared files.
  1233.  
  1234. The server will return whether it is executing in user level
  1235. security  mode  or share level security mode in the extended
  1236. Negotiate response protocol (when the LANMAN 1.0 dialect has
  1237. been  selected).   This  allows the consumer to know whether
  1238. the "User Logon" information is needed in the Session Set Up
  1239. protocol.
  1240.  
  1241. A server in user level security mode (having negotiated core
  1242. protocol with the consumer node) will accept the core format
  1243. of the Tree Connect command and do the following:
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. SMB Protocol Extensions    - 20 -           November 7, 1988
  1259.  
  1260.  
  1261.  
  1262.         If the consumer's node name is defined as an account-name (and the Tree
  1263.         Connect passwd matches), the "user logon" will be performed using
  1264.         that value.
  1265.  
  1266.         If the above fails, the server may fail the request or assign a default
  1267.         account name (probably allowing limited access).
  1268.  
  1269.         The value in smb_uid will then be ignored and all access will be validated
  1270.         assuming the account name selected above.
  1271.  
  1272. The above allows servers in "user level  security  mode"  to
  1273. accommodate core protocol users.
  1274.  
  1275. 5.3.  Connection Protocols
  1276.  
  1277. The NET SHARE command generates no  network  messages.   The
  1278. server remembers the pathname's netname and the password for
  1279. later verification.
  1280.  
  1281. The NET USE command generates a tree  connect  message  con-
  1282. taining  the  netname  and  the  associated password. If the
  1283. server is in "user level security mode"  the  UID,  account-
  1284. name  and  account-password  will  also  be supplied via the
  1285. "Session Set Up" protocol.  If the no Session Set Up  proto-
  1286. col  is received, the server will try the consumer node name
  1287. as described above.
  1288.  
  1289. On receiving the Tree Connect  protocol,  the  serving  node
  1290. verifies  the name/password combination and returns an error
  1291. code or an identifier (the TID).
  1292.  
  1293. The short-name is included in the Tree Connect request  mes-
  1294. sage  and the identifier (TID) identifying the connection is
  1295. returned in the smb_tid field.  The meaning of this identif-
  1296. ier (TID) is server specific; the requester must not associ-
  1297. ate any specific meaning to it.
  1298.  
  1299. The server makes whatever use of the TID it  desires.   Nor-
  1300. mally  it  is  an index into a server table which allows the
  1301. server to optimize its response.
  1302.  
  1303. The consumer must associate the identifier with  the  device
  1304. name being redirected (specified in the NET USE) and include
  1305. the  appropriate  identifier  (TID)  for  all  network  file
  1306. accesses made.
  1307.  
  1308.  
  1309. 5.4.  USER ADMINISTRATION
  1310.  
  1311. The LANMAN 1.0 extended protocol makes use  of  the  "Server
  1312. Based"  method of user administration and allows for "Consu-
  1313. mer Based" user administration.
  1314.  
  1315.  
  1316.  
  1317.  
  1318. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. SMB Protocol Extensions    - 21 -           November 7, 1988
  1325.  
  1326.  
  1327. The server based approach is similar to the consumer authen-
  1328. tication  scheme  used by the core protocol.  It is based on
  1329. the principle that the consumer processors may or may not be
  1330. trusted to authenticate users.  It assumes that the LAN con-
  1331. nects autonomous systems that are willing to make some  sub-
  1332. set of their local files available to remote users.
  1333.  
  1334. On some networks, there may be centralized logon servers  or
  1335. some  other  means  to guarantee that a global UID is unique
  1336. and valid.  In these  networks,  the  consumer  will  merely
  1337. introduce  a new UID into the SMB header and the server will
  1338. know who it represents and that it is valid.  This is  known
  1339. as  a  "consumer  based"  approach  in  that the consumer is
  1340. responsible for validating the users.
  1341.  
  1342. The protocol supports both types of administration  in  that
  1343. the  server  may  respond  with ERRbaduid which will require
  1344. that the consumer send a Session Set Up command  to  "logon"
  1345. the  user  or  it may just accept a new UID from a "trusted"
  1346. consumer node.
  1347.  
  1348. Each server may maintain a list of valid  users  (or  invoke
  1349. some  other  means  of  user validation). It may then verify
  1350. every access by these users.  It can  therefore  accept  any
  1351. and all transport connections offered.
  1352.  
  1353. A UID is selected by  the  consumer  and  validated  by  the
  1354. server via the Session Set Up protocol.
  1355.  
  1356. This UID is used to both identify the user on all subsequent
  1357. requests  and  prove  to  the server that this user has been
  1358. authenticated.
  1359.  
  1360. The consumer must  associate  the  UID  with  the  user  and
  1361. include  the  appropriate  identifier  (UID) for all network
  1362. file accesses made by that user.
  1363.  
  1364. From the servers point of view the user identifier (UID)  is
  1365. therefore  NOT  associated  with  a particular offer (shared
  1366. resource identified by the TID) but the authenticated  user.
  1367. The  UID may be used to access any shared resource which has
  1368. been connected to via the Tree Connect protocol.
  1369.  
  1370.  
  1371. 5.5.  FILE SECURITY
  1372.  
  1373. The specific file security model enforced  by  a  server  in
  1374. "user  level  security  mode"  is  outside the scope of this
  1375. document, however,  the types of access a  user  may  expect
  1376. are discussed here.
  1377.  
  1378. As was true in core protocol, the user must be  prepared  to
  1379. be denied access.
  1380.  
  1381.  
  1382.  
  1383.  
  1384. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. SMB Protocol Extensions    - 22 -           November 7, 1988
  1391.  
  1392.  
  1393. With LANMAN 1.0 extended protocol and the  server  in  "user
  1394. level  security  mode"  the user should expect to be allowed
  1395. differing access to different files within the  same  shared
  1396. Tree structure.  He/she may be allowed to read one file only
  1397. and yet be able to write to others in the same directory.
  1398.  
  1399. Files may have specific  access  permissions  for  specified
  1400. users  or  groups,  and  another  set of permissions for all
  1401. other users.
  1402.  
  1403. The protocol provides no way to set or  modify  the  permis-
  1404. sions  of  the  files  and directories on the server.  It is
  1405. expected that the "system administrator" of the server  will
  1406. have a mechanism to set and modify permissions.
  1407.  
  1408. When files are created on the server, the files  by  default
  1409. take on the permissions defined by the parent directory.
  1410.  
  1411.  
  1412. 5.6.  FILE ATTRIBUTES AND TYPES
  1413.  
  1414. The LANMAN 1.0 Extended File Sharing  Protocol  may  support
  1415. additional  attributes  to  those specified in the Core File
  1416. Sharing Protocol.
  1417.  
  1418.  
  1419. The LANMAN 1.0 Extended File Sharing  Protocol  may  support
  1420. additional  file  types  to those specified in the Core File
  1421. Sharing Protocol.  The following file  types  will  be  sup-
  1422. ported by the LANMAN 1.0 implementation:
  1423.  
  1424.         named pipes
  1425.         message mode named pipes
  1426.         I/O devices
  1427.         mail slots
  1428.  
  1429.  
  1430. NAMED PIPES
  1431.  
  1432. Named pipes provide a new facility which allows pipes to  be
  1433. named  and  act  like full duplex virtual circuits between a
  1434. pair of endpoints.
  1435.  
  1436. Named Pipe Features
  1437.  
  1438. o    Allows LANMAN 1.0 pipes to be named and accessed across
  1439.      a network.
  1440.  
  1441.  
  1442. o    Once  created,  named   pipes   can   be   opened   and
  1443.      read/written  like  standard  files,  i.e., using Open,
  1444.      Read, Write, and Close protocols.
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456. SMB Protocol Extensions    - 23 -           November 7, 1988
  1457.  
  1458.  
  1459. o    Named pipes support message  as  well  as  byte  stream
  1460.      modes.
  1461.  
  1462.  
  1463. o    Byte stream mode lets processes  read  and  write  byte
  1464.      streams,  exactly  like byte conventional pipes, except
  1465.      the pipe is full-duplex, emulating a virtual circuit.
  1466.  
  1467.  
  1468. o    Message mode lets processes read and write  streams  of
  1469.      messages (as opposed to bytes).  Message mode is optim-
  1470.      ized for peer-to-peer communication between  remote  as
  1471.      well as local processes.
  1472.  
  1473.  
  1474. o    Named  pipes  can  be  serially  re-used  by  different
  1475.      clients (closed and reopened by another process).
  1476.  
  1477.  
  1478. o    A serving process can create multiple identically named
  1479.      pipes  so  that  multiple  clients opening to that name
  1480.      will get distinct pipes to the serving process.
  1481.  
  1482.  
  1483. o    Unmodified core consumers can access named pipes  on  a
  1484.      OS/2  server  as  if  they  were accessing a sequential
  1485.      file.
  1486.  
  1487.  
  1488.  
  1489.  
  1490. I/O DEVICES
  1491.  
  1492. The LANMAN 1.0 extended  protocol  allows  a  device  to  be
  1493. opened for driver level I/O.  This provides direct access to
  1494. real time and interactive devices such as modems,  scanners,
  1495. etc..  Two such types of devices are defined, COM - communi-
  1496. cation devices like modems or terminals and  LPT  -  printer
  1497. devices which will be accessed directly (not spooled).
  1498.  
  1499.  
  1500. 5.6.1.  REPRESENTATION
  1501.  
  1502. On LANMAN 1.0 Extended Protocol servers the attribute  field
  1503. has  the  following  format  (bit0  is the least significant
  1504. bit).  This field matches that used by OS/2.
  1505.  
  1506.         bit0 - read only file
  1507.         bit1 - "hidden" file
  1508.         bit2 - system file
  1509.         bit3 - reserved
  1510.         bit4 - directory
  1511.         bit5  - archive file
  1512.         bits6-15 - reserved (must be zero)
  1513.  
  1514.  
  1515.  
  1516. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. SMB Protocol Extensions    - 24 -           November 7, 1988
  1523.  
  1524.  
  1525. The LANMAN 1.0 Extended  resource  type  field  defines  the
  1526. additional resource types:
  1527.  
  1528.  
  1529.                0 - Disk file or directory as defined in the attribute field.
  1530.                1 - FIFO (named pipe)
  1531.                2 - Named pipe (message mode)
  1532.                3 - LPT (printer) Device
  1533.                4 - COM (communication) Device
  1534.  
  1535.  
  1536. 6.  TIMEOUTS
  1537.  
  1538. The LANMAN 1.0 extended protocol provides for actions timing
  1539. out on the server.  Actions which may time out include:
  1540.  
  1541. o    Opens (to I/O devices)
  1542.  
  1543. o    Locks (on records within files)
  1544.  
  1545. o    read/write (on I/O devices)
  1546.  
  1547.  
  1548. If a server implementation can not support timeouts, then an
  1549. error  can  be returned just as if a timeout had occurred if
  1550. the resource is not available immediately upon request.
  1551.  
  1552.  
  1553. 7.  QUEUEING
  1554.  
  1555. The LANMAN 1.0 extended protocol provides  for  Queuing  for
  1556. Opens  of  I/O devices and for bytes within a file to become
  1557. free (unlocked).  If a server implementation can not support
  1558. queuing  and  the  resource being queued for is busy, simply
  1559. respond with a "busy" error just as if  the  queued  request
  1560. had  timed  out.  The same thing could happen if queuing was
  1561. supported but the queue remained full.
  1562.  
  1563. 8.  EXCEPTION HANDLING
  1564.  
  1565. Exception handling within the LANMAN 1.0  extended  protocol
  1566. environment  is  an extension to the core techniques.  It is
  1567. built upon the various environments supported  by  the  file
  1568. sharing  protocol.  When  any  environment  is dissolved (in
  1569. either an  orderly  or  disorderly  fashion)  all  contained
  1570. environments  are  dissolved.  The hierarchy of environments
  1571. is summarized below:
  1572.  
  1573.         Server Based User Authentication:
  1574.  
  1575.           Virtual Circuit Environment
  1576.               TID
  1577.                   PID
  1578.                   FID
  1579.  
  1580.  
  1581.  
  1582. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. SMB Protocol Extensions    - 25 -           November 7, 1988
  1589.  
  1590.  
  1591. As can be seen from the summary, the Virtual Circuit (VC) is
  1592. the key environment.  When a VC environment (the last VC) is
  1593. dissolved the server  processes  (or  equivalent)  are  ter-
  1594. minated;  the TIDs and FIDs are invalidated, and outstanding
  1595. requests are dropped -- responses will not be generated.
  1596.  
  1597. The termination of a TID will cause the termination  of  all
  1598. PIDs  (or  equivalent)  created  in  support of that TID and
  1599. close of all FIDs opened using the TID as  the  access  key.
  1600. The  destruction  of  PIDs  and  FIDs has no affect on other
  1601. environments.
  1602.  
  1603. The rules for VC establishment and dissolution are identical
  1604. to those enforced by the core file sharing protocol with the
  1605. following exceptions:
  1606.  
  1607. o    If a server receives a VC establishment request from  a
  1608.      consumer  with  which it is already conversing, it will
  1609.      be accepted as an "additional" VC to be used for  rapid
  1610.      data  movement  protocols.  The negotiate protocol will
  1611.      then be used to indicate if the consumer  intends  this
  1612.      VC  to  be the first VC or as an additional VC.  If the
  1613.      consumer specified that this was to be  the  first  VC,
  1614.      all other VCs to that consumer may be aborted.
  1615.  
  1616.  
  1617. o    A server may drop the VC to a consumer at any  time  if
  1618.      the  consumer  is  generating illogical requests.  How-
  1619.      ever, wherever possible the server should first  return
  1620.      an  error  code to the consumer indicating the cause of
  1621.      the VC abort.
  1622.  
  1623.  
  1624. o    If a server gets a hard error on a VC (such as  a  send
  1625.      failure) all VCs to that consumer may be aborted.
  1626.  
  1627.  
  1628. o    A server may drop the VC on last Tree Disconnect,  how-
  1629.      ever,  we  recommend  that  the  drop be performed only
  1630.      after an automatic timeout time has passed or when  the
  1631.      VC  resource  is needed.  This will help performance in
  1632.      that the VC  will  not  need  to  be  reestablished  if
  1633.      activity occurs again before the "timeout" time.
  1634.  
  1635.      Some  server  implementations  will  perform  a   "soft
  1636.      timeout"  where  if no tree connects (and thus no other
  1637.      resources) are in use on a VC, it  may  age  until  the
  1638.      server elects to drop it allowing other users access.
  1639.  
  1640.      Other implementations include a "hard timeout" in  that
  1641.      if  a  VC has not been used for a (system administrator
  1642.      defined) amount of time, the VC will  be  aborted  des-
  1643.      troying  all  Tree  Connections etc. which are still on
  1644.      the session.
  1645.  
  1646.  
  1647.  
  1648. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654. SMB Protocol Extensions    - 26 -           November 7, 1988
  1655.  
  1656.  
  1657.      Others use an as needed basis where one or both of  the
  1658.      above  methods  are used but only when Virtual Circuits
  1659.      are needed.
  1660.  
  1661.      A consumer is always expected to be able to reestablish
  1662.      in the case where the VC was dropped with no valid tree
  1663.      connects (and thus no other resources) on it.
  1664.  
  1665.      For Hard timeouts, the user may receive errors and have
  1666.      to  reconnect (do another NET USE) in order to reestab-
  1667.      lish the session.  This is  similar  to  many  "switch"
  1668.      timeouts on multi-user systems.
  1669.  
  1670.  
  1671. On write behind activity, a subsequent write or close of the
  1672. file  will  return  the  fact  that a previous write failed.
  1673. Normally write behind failures  are  limited  to  hard  disk
  1674. errors and device out of space.
  1675.  
  1676.  
  1677. 9.  EXTENDED PROTOCOL
  1678.  
  1679. The format of enhanced and new commands is defined  commenc-
  1680. ing  at  the  smb_wct  field.  All messages will include the
  1681. standard SMB header defined in section 1.0.  When  an  error
  1682. is encountered a server may choose to return only the header
  1683. portion of the response (i.e., smb_wct and smb_bcc both con-
  1684. tain zero).
  1685.  
  1686. 9.1.  CORE SERVICE ENHANCEMENTS
  1687.  
  1688. The  LANMAN  1.0  extended  protocol   includes   functional
  1689. enhancements to some core services, and these are defined in
  1690. this section.  Enhancements to services can only add to  the
  1691. service's  existing  semantics,  i.e., additional values for
  1692. parameters may be introduced and new parameters  added,  but
  1693. parameters  cannot  be  removed or used for a different pur-
  1694. pose.  All "core" requests must continue  to  function  with
  1695. the  enhanced  command.  If these rules cannot be followed a
  1696. new command must be defined.
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720. SMB Protocol Extensions    - 27 -           November 7, 1988
  1721.  
  1722.  
  1723. 9.1.1.  NEGOTIATE
  1724.  
  1725. Request Format is unchanged in order  to  remain  compatible
  1726. with earlier versions and the core protocol.
  1727.  
  1728. Enhanced Response Format  (returned  only  when  LANMAN  1.0
  1729. dialect is selected):
  1730.  
  1731.   BYTE   smb_wct;          /* value = 13 */
  1732.   WORD   smb_index;        /* index identifying dialect selected */
  1733. + WORD   smb_secmode;      /* security mode:
  1734.                            bit 0 - 1 = User level security, 0 =  Share level security.  */
  1735.                            bit 1 - 1 = encrypt passwords , 0 =  do not encrypt passwords */
  1736. + WORD   smb_maxxmt;       /* max transmit buffer size server supports,  1k min */
  1737. + WORD   smb_maxmux;       /* max pending multiplexed requests server supports */
  1738. + WORD   smb_maxvcs;       /* max VCs per server/consumer session supported */
  1739. + WORD   smb_blkmode;      /* block read/write mode support :
  1740.                            bit 0 - Read Block Raw supported (65,535 bytes max).
  1741.                            bit 1 - Write Block Raw supported (65,535 bytes max). */
  1742. +DWORD   smb_sesskey;      /* Session Key (unique token identifying session) */
  1743. + WORD   smb_srv_time;     /* server's current time (hhhhh mmmmmm xxxxx)
  1744.                            where 'xxxxx' is in two second increments */
  1745. + WORD   smb_srv_date;     /* server's current date (yyyyyyy mmmm ddddd) */
  1746. + WORD   smb_srv_tzone;    /* server's current time zone */
  1747. +DWORD   smb_rsvd;         /* reserved */
  1748.   WORD   smb_bcc;          /* value = (size of smb_cryptkey) */
  1749. + BYTE   smb_cryptkey[];   /* Key used for password encryption */
  1750.  
  1751. + Additional parameters
  1752.  
  1753. In addition, if bit ZERO (low order bit) of smb_flg  is  set
  1754. (returned)  from the server in the Negotiate response proto-
  1755. col header, this indicates that the server supports the "sub
  1756. dialect"  consisting  of  the LockandRead and WriteandUnlock
  1757. protocols.
  1758.  
  1759.  
  1760. Service Enhancement:
  1761.  
  1762. The dialect string for  the  LANMAN  1.0  extended  protocol
  1763. specified in this document is:
  1764.  
  1765.      LANMAN1.0
  1766.  
  1767. Having selected LANMAN 1.0  as  the  dialect,  the  consumer
  1768. needs to be informed of whether or not the server is execut-
  1769. ing in "share level security mode" or "user  level  security
  1770. mode"  in  order to format appropriate Session Set Up proto-
  1771. cols.
  1772.  
  1773. Whether or not Read Block Raw (where up to 65,535  bytes  of
  1774. data  may  be read directly into user space) is supported is
  1775. returned.
  1776.  
  1777.  
  1778.  
  1779.  
  1780. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786. SMB Protocol Extensions    - 28 -           November 7, 1988
  1787.  
  1788.  
  1789. Whether or not Write Block Raw (where up to 65,535 bytes  of
  1790. data  may  be written directly from user space) is supported
  1791. is returned.
  1792.  
  1793. The smb_sesskey value is used  to  validate  additional  VCs
  1794. added to a session (via the Session Set Up protocol).
  1795.  
  1796. The minimum server SMB  buffer  size  (smb_maxxmt)  is  1024
  1797. bytes  (1k).   This provides sufficient room for most proto-
  1798. cols including the simple  "request-response"  mode  of  the
  1799. IOCTL protocol.
  1800.  
  1801. Note that smb_maxxmt returned in the NEGOTIATE  response  is
  1802. the  server buffer size supported.  Thus this is the max SMB
  1803. message size which the consumer  can  send  to  the  server.
  1804. This  size  may  be  larger than smb_bufsize returned to the
  1805. server from the consumer via the  SESSION SETUP and X proto-
  1806. col  which  is the maximum SMB message size which the server
  1807. may send to the consumer.
  1808.  
  1809. Thus if the server's buffer size (as indicated in smb_maxxmt
  1810. on  NEGOTIATE)  were  4k and the consumer's buffer size were
  1811. only 2k (as indicated in smb_bufsize on  SESSION  SETUP  and
  1812. X),   The  consumer  could  send  up  to 4k (standard) write
  1813. requests but must only request up to 2k for (standard)  read
  1814. requests.   The  max  transaction  response  from the server
  1815. would also be 2k.
  1816.  
  1817. LANMAN 1.0 will use a cryptkey of 8 bytes.
  1818.  
  1819.  
  1820.  
  1821. The date is in the following format:
  1822.   bits:
  1823.        1111 11
  1824.        5432 1098 7654 3210
  1825.        yyyy yyym mmmd dddd
  1826. where:
  1827.       y - bit of year 0-119 (1980-2099)
  1828.       m - bit of month 1-12
  1829.       d - bit of day 1-31
  1830.  
  1831.  
  1832.  
  1833. The time is in the following format:
  1834.   bits:
  1835.        1111 11
  1836.        5432 1098 7654 3210
  1837.        hhhh hmmm mmmx xxxx
  1838. where:
  1839.       h - bit of hour (0-23)
  1840.       m - bit of minute (0-59)
  1841.       x - bit of 2 second increment
  1842.  
  1843.  
  1844.  
  1845.  
  1846. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852. SMB Protocol Extensions    - 29 -           November 7, 1988
  1853.  
  1854.  
  1855. Negotiate may generate the following errors.
  1856.  
  1857.         Error Class ERRDOS
  1858.  
  1859.           <implementation specific>
  1860.  
  1861.  
  1862.         Error Class ERRSRV
  1863.  
  1864.           ERRerror
  1865.           <implementation specific>
  1866.  
  1867.  
  1868.         Error Class ERRHRD
  1869.  
  1870.           <implementation specific>
  1871.  
  1872.  
  1873. 9.2.  ADDITIONAL SERVICES
  1874.  
  1875. This LANMAN 1.0 Extension Set includes  all  functions  con-
  1876. sidered  necessary to provide transparency for all essential
  1877. or frequently used file access functions.  OS/2 requirements
  1878. have  been  used  as  a  guide  for  selecting  the services
  1879. included here; when other common operating systems are  con-
  1880. sidered in more detail it may prove necessary to expand this
  1881. set.
  1882.  
  1883. The protocols in this section are presented in  alphabetical
  1884. order.
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918. SMB Protocol Extensions    - 30 -           November 7, 1988
  1919.  
  1920.  
  1921. 9.2.1.  COPY
  1922.  
  1923. Request Format:
  1924.  
  1925.   BYTE   smb_wct;          /* value = 3 */
  1926.   WORD   smb_tid2;         /* second (destination) path tid */
  1927.   WORD   smb_ofun;         /* what to do if destination file exists */
  1928.   WORD   smb_flags;        /* flags to control copy operations:
  1929.                            bit 0 - destination must be a file.
  1930.                            bit 1 - destination must be a directory.
  1931.                            bit 2 - copy destination mode: 0 = binary, 1 = ASCII.
  1932.                            bit 3 - copy source mode: 0 = binary, 1 = ASCII.
  1933.                            bit 4 - verify all writes. */
  1934.   WORD   smb_bcc;          /* minimum value = 2 */
  1935.   BYTE   smb_path[];       /* pathname of source file */
  1936.   BYTE   smb_new_path[];   /* pathname of destination file */
  1937.  
  1938. Response Format:
  1939.  
  1940.   BYTE   smb_wct;         /* value = 1 */
  1941.   WORD   smb_cct;         /* number of files copied */
  1942.   WORD   smb_bcc;         /* minimum value = 0 */
  1943.   BYTE   smb_errfile[];   /* pathname of file where error occured - ASCIIZ */
  1944.  
  1945. Service:
  1946.  
  1947.  
  1948. The file referenced by smb_path is copied  to  smb_new_path.
  1949. Both  smb_path  and  smb_new_path must refer to paths on the
  1950. server.  The server must do any necessary access  permission
  1951. checks on both the source and the destination paths.
  1952.  
  1953. The TID in smb_tid of the  header  is  associated  with  the
  1954. source  while  smb_tid2  is associated with the destination.
  1955. These TID fields may contain the  same  or  differing  valid
  1956. TIDs.   Note  that smb_tid2 can be set to -1 indicating that
  1957. this is to be the same TID as the  TID  in  smb_tid  of  the
  1958. header.  This allows use of the copy protocol with TCONandX.
  1959.  
  1960. The source path must refer to an  existing  file  or  files.
  1961. Wild  Cards  are  permitted.  Source files specified by Wild
  1962. Cards are processed until an error is  encountered.   If  an
  1963. error  is  encountered,  the  expanded  name  of the file is
  1964. returned in smb_errfile.  The  error  code  is  returned  in
  1965. smb_err.
  1966.  
  1967. The destination path can refer to either a file or a  direc-
  1968. tory.
  1969.  
  1970. The destination can be required to be a file or a  directory
  1971. by  smb_flags  bits.  If neither bit is set, the destination
  1972. may be either a file or a directory.
  1973.  
  1974. Wild Cards are not permitted in the destination path.
  1975.  
  1976.  
  1977.  
  1978. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984. SMB Protocol Extensions    - 31 -           November 7, 1988
  1985.  
  1986.  
  1987. If the destination is a file and the  source  contains  Wild
  1988. Cards,  the  destination  file  will  either be truncated or
  1989. appended to at the start of the operation (depending on bits
  1990. in  smb_ofun)  .   Subsiquent files will then be appended to
  1991. the file.
  1992.  
  1993.  
  1994.  
  1995. smb_ofun bit field mapping:
  1996.   bits:
  1997.        1111 11
  1998.        5432 1098 7654 3210
  1999.        rrrr rrrr rrrC rrOO
  2000.  
  2001.   where:
  2002.        O - Open (action to  be  taken  if  destination  file
  2003. exists).
  2004.          0 - Fail.
  2005.          1 - Append file.
  2006.          2 - Truncate file.
  2007.  
  2008.        r - reserved (must be zero).
  2009.  
  2010.        C - Create (action to be taken  if  destination  file
  2011. does not exist).
  2012.          0 -- Fail.
  2013.          1 -- Create file.
  2014.  
  2015.  
  2016. Copy may generate the following errors.
  2017.  
  2018.         Error Class ERRDOS
  2019.  
  2020.           ERRbadfile
  2021.           ERRbadpath
  2022.           ERRfileexists
  2023.           ERRnoaccess
  2024.           ERRnofiles
  2025.           ERRbadshare
  2026.           <implementation specific>
  2027.  
  2028.  
  2029.         Error Class ERRSRV
  2030.  
  2031.           ERRerror
  2032.           ERRinvnid
  2033.           ERRnosupport
  2034.           ERRaccess
  2035.           <implementation specific>
  2036.  
  2037.  
  2038.         Error Class ERRHRD
  2039.  
  2040.           <implementation specific>
  2041.  
  2042.  
  2043.  
  2044. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050. SMB Protocol Extensions    - 32 -           November 7, 1988
  2051.  
  2052.  
  2053. 9.2.2.  ECHO
  2054.  
  2055. Request Format:
  2056.  
  2057.   BYTE   smb_wct;      /* value = 01 */
  2058.   WORD   smb_reverb;   /* number of times to echo data back */
  2059.   WORD   smb_bcc;      /* minimum value = 4 */
  2060.   BYTE   smb_data[];   /* data to echo back */
  2061.  
  2062.  
  2063.  
  2064. Response Format (one for each echo requested):
  2065.  
  2066.   BYTE   smb_wct;      /* value = 1 */
  2067.   WORD   smb_seq;      /* sequence number of this echo */
  2068.   WORD   smb_bcc;      /* minimum value = 4 */
  2069.   BYTE   smb_data[];   /* echo data */
  2070.  
  2071.  
  2072.  
  2073. Service:
  2074.  
  2075. The ECHO protocol is used to test the VC and to see  if  the
  2076. server  is  still responding.  It is also used to see if the
  2077. TID is still valid.
  2078.  
  2079. When this protocol is used, other requests may be active  on
  2080. the  multiplexed  VC.  The server will respond with the zero
  2081. or  more  response  protocol  messages   as   requested   in
  2082. smb_reverb.
  2083.  
  2084. Each response echos the data sent (note - data size  may  be
  2085. zero).  If smb_reverb is zero, no response will be sent.
  2086.  
  2087. There is no need for a valid TID field in  smb_tid  for  the
  2088. success  of this protocol (a null TID is defined as 0xFFFF).
  2089. However, if a TID is present, then the server must check the
  2090. TID  for  validity  because the consumer may be sending this
  2091. protocol to see if the TID is  still  valid.   ERRSRV  error
  2092. class and ERRinvnid error code should be set in the protocol
  2093. response if the TID is invalid.
  2094.  
  2095. The flow for the ECHO protocol is:
  2096.  
  2097.      consumer ----> ECHO request (data) >------> server
  2098.      consumer <--< ECHO response 1 (data) <----- server
  2099.      consumer <--< ECHO response 2 (data) <----- server
  2100.      .                       .                        .
  2101.      consumer <--< ECHO response n (data) <----- server
  2102.  
  2103.  
  2104. ECHO may generate the following errors.
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116. SMB Protocol Extensions    - 33 -           November 7, 1988
  2117.  
  2118.  
  2119.  
  2120.         Error Class ERRDOS
  2121.  
  2122.           <implementation specific>
  2123.  
  2124.  
  2125.         Error Class ERRSRV
  2126.  
  2127.           ERRerror
  2128.           ERRnosupport
  2129.           <implementation specific>
  2130.  
  2131.  
  2132.         Error Class ERRHRD
  2133.  
  2134.           <implementation specific>
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182. SMB Protocol Extensions    - 34 -           November 7, 1988
  2183.  
  2184.  
  2185. 9.2.3.  FIND
  2186.  
  2187. Request Format: (same as core Search Protocol)
  2188.  
  2189.   BYTE   smb_wct;            /* value = 2 */
  2190.   WORD   smb_count;          /* max number of entries to find */
  2191.   WORD   smb_attr;           /* search attribute */
  2192.   WORD   smb_bcc;            /* minimum value = 5 */
  2193.   BYTE   smb_ident1;         /* ASCII  (04) */
  2194.   BYTE   smb_pathname[];     /* filename (may contain global characters) */
  2195.   BYTE   smb_ident2;         /* Variable Block (05) */
  2196.   WORD   smb_keylen;         /* resume key length (zero if "Find First") */
  2197.   BYTE   smb_resumekey[*];   /* "Find Next" key (* = value of smb_keylen) */
  2198.  
  2199.  
  2200.  
  2201. Response Format: (same as core Search Protocol)
  2202.  
  2203.   BYTE   smb_wct;       /* value = 1 */
  2204.   WORD   smb_count;     /* number of entries found */
  2205.   WORD   smb_bcc;       /* minimum value = 3 */
  2206.   BYTE   smb_ident;     /* Variable Block (05) */
  2207.   WORD   smb_datalen;   /* data length */
  2208.   BYTE   smb_data[*];   /* directory entries */
  2209.  
  2210.  
  2211.  
  2212. Directory Information Entry (dir_info) Format: (same as core
  2213. Search Protocol)
  2214.  
  2215.   BYTE   find_buf_reserved[21];   /* reserved (resume_key) */
  2216.   BYTE   find_buf_attr;           /* attribute */
  2217.   WORD   find_buf_time;           /* modification time (hhhhh mmmmmm xxxxx)
  2218.                                   where 'xxxxx' is in two second increments */
  2219.   WORD   find_buf_date;           /* modification date (yyyyyyy mmmm ddddd) */
  2220.  DWORD   find_buf_size;           /* file size */
  2221.   BYTE   find_buf_pname[13];      /* file name -- ASCII (null terminated) */
  2222.  
  2223.  
  2224.  
  2225. The resume_key has the following format:
  2226.  
  2227.   BYTE   sr_res;         /* reserved:
  2228.                            bit    7 - reserved for consumer use
  2229.                            bit  5,6 - reserved for system use (must be preserved)
  2230.                            bits 0-4 - reserved for server (must be preserved) */
  2231.   BYTE   sr_name[11];    /* pathname sought.  Format:
  2232.                            0-3 character extension, left justified (in last 3 chars) */
  2233.   BYTE   sr_findid[1];   /* uniquely identifies find through find close */
  2234.   BYTE   sr_server[4];   /* available for server use (must be non-zero) */
  2235.   BYTE   sr_res[4];      /* reserved for consumer use */
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248. SMB Protocol Extensions    - 35 -           November 7, 1988
  2249.  
  2250.  
  2251. Service:
  2252.  
  2253. The Find protocol finds the  directory  entry  or  group  of
  2254. entries  matching the specified file pathname.  The filename
  2255. portion of the pathname may contain global (wild card) char-
  2256. acters.
  2257.  
  2258. The Find protocol is used to  match  the  find  OS/2  system
  2259. call.  The protocols "Find ", "Find Unique" and "Find Close"
  2260. are methods of reading (or searching)  a  directory.   These
  2261. protocols may be used in place of the core "Search" protocol
  2262. when LANMAN 1.0 dialect has been negotiated.  There  may  be
  2263. cases where the Search protocol will still be used.
  2264.  
  2265. The format of the Find protocol is  the  same  as  the  core
  2266. "Search"  protocol.  The difference is that the directory is
  2267. logically Opened with a Find protocol and  logically  closed
  2268. with  the  Find  Close  protocol.  This allows the Server to
  2269. make better use of its resources.  Search buffers  are  thus
  2270. held   (allowing   search   resumption   via   presenting  a
  2271. "resume_key") until a Find Close protocol is received.   The
  2272. sr_findid  field  of  each resume key is a unique identifier
  2273. (within the session) of the search from "Find" through "Find
  2274. close".   Thus  if  the consumer does "Find ahead", any find
  2275. buffers containing resume keys with the matching find id may
  2276. be released when the Find Close is requested.
  2277.  
  2278. As is true of a  failing  open,  if  a  Find  request  (Find
  2279. "first"  request where resume_key is null) fails (no entries
  2280. are found), no find close protocol is expected.
  2281.  
  2282. If no global characters are present, a "Find Unique"  proto-
  2283. col  should  be  used  (only  one entry is expected and find
  2284. close need not be sent).
  2285.  
  2286. The file path name in the request specifies the file  to  be
  2287. sought.   The  attribute field indicates the attributes that
  2288. the file must have.  If the attribute is zero then only nor-
  2289. mal  files  are  returned.   If  the  system file, hidden or
  2290. directory  attributes  are  specified  then  the  search  is
  2291. inclusive  -- both the specified type(s) of files and normal
  2292. files are returned.  If the volume label attribute is speci-
  2293. fied then the search is exclusive, and only the volume label
  2294. entry is returned
  2295.  
  2296. The  max-count  field  specifies  the  number  of  directory
  2297. entries  to  be returned.  The response will contain zero or
  2298. more directory entries as determined by  the  count-returned
  2299. field.   No  more  than  max-count entries will be returned.
  2300. Only entries that match the sought  filename/attribute  will
  2301. be returned.
  2302.  
  2303. The resume_key field must be null (length = 0) on  the  ini-
  2304. tial  ("Find First") find request.  Subsequent find requests
  2305.  
  2306.  
  2307.  
  2308. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314. SMB Protocol Extensions    - 36 -           November 7, 1988
  2315.  
  2316.  
  2317. intended to continue a search must  contain  the  resume_key
  2318. field  extracted from the last directory entry of the previ-
  2319. ous response.  The resume_key field is  self-contained,  for
  2320. on  calls  containing  a resume_key neither the attribute or
  2321. pathname fields will be valid in the request. A find request
  2322. will  terminate  when either the requested maximum number of
  2323. entries that match the named file are found, or the  end  of
  2324. directory  is  reached without the maximum number of matches
  2325. being found.  A response  containing  no  entries  indicates
  2326. that  no  matching  entries  were found between the starting
  2327. point of the search and the end of directory.
  2328.  
  2329. There may be multiple matching entries in response to a sin-
  2330. gle  request  as Find supports "wild cards" in the file name
  2331. (last component of the pathname). "?" is the wild  card  for
  2332. single  characters,  "*"  or "null" will match any number of
  2333. filename characters within a single  part  of  the  filename
  2334. component.   The  filename  is  divided into two parts -- an
  2335. eight character name and a three character  extension.   The
  2336. name and extension are divided by a ".".
  2337.  
  2338. If a filename part commences with  one  or  more  "?"s  then
  2339. exactly  that  number  of  characters will be matched by the
  2340. Wild Cards, e.g., "??x" will equal "abx" but not  "abcx"  or
  2341. "ax".   When  a filename part has trailing "?"s then it will
  2342. match the specified number  of  characters  or  less,  e.g.,
  2343. "x??"  will  match  "xab", "xa" and "x", but not "xabc".  If
  2344. only "?"s are present in the filename part, then it is  han-
  2345. dled as for trailing "?"s
  2346.  
  2347. "*" or "null" match entire pathname parts, thus  "*.abc"  or
  2348. ".abc"  will  match  any  file  with  an extension of "abc".
  2349. "*.*", "*" or "null" will match all files in a directory.
  2350.  
  2351. Unprotected servers require the requester to have read  per-
  2352. mission  on  the  subtree  containing the directory searched
  2353. (the share specifies read permission).
  2354.  
  2355. Protected servers require the requester to  have  permission
  2356. to search the specified directory.
  2357.  
  2358. If a Find requests more data than can be placed in a message
  2359. of  the max-xmit-size for the TID specified, the server will
  2360. return only the number of entries which will fit.
  2361.  
  2362. The number of entries returned will be the minimum of:
  2363.  
  2364.         1. The number of entries requested.
  2365.         2. The number of (complete) entries that will fit in the negotiated SMB buffer.
  2366.         3. The number of entries that match the requested name pattern and attributes.
  2367.  
  2368.  
  2369. The error ERRnofiles set in smb_err field  of  the  response
  2370. header  or  a  zero  value  in  smb_count  of  the  response
  2371.  
  2372.  
  2373.  
  2374. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380. SMB Protocol Extensions    - 37 -           November 7, 1988
  2381.  
  2382.  
  2383. indicates no matching entry was found.
  2384.  
  2385. The resume search key returned  along  with  each  directory
  2386. entry  is  a  server  defined key which when returned in the
  2387. Find Next  protocol,  allows  the  directory  search  to  be
  2388. resumed  at the directory entry following the one denoted by
  2389. the resume search key.
  2390.  
  2391.  
  2392.  
  2393. The date is in the following format:
  2394.   bits:
  2395.        1111 11
  2396.        5432 1098 7654 3210
  2397.        yyyy yyym mmmd dddd
  2398. where:
  2399.       y - bit of year 0-119 (1980-2099)
  2400.       m - bit of month 1-12
  2401.       d - bit of day 1-31
  2402.  
  2403.  
  2404.  
  2405. The time is in the following format:
  2406.   bits:
  2407.        1111 11
  2408.        5432 1098 7654 3210
  2409.        hhhh hmmm mmmx xxxx
  2410. where:
  2411.       h - bit of hour (0-23)
  2412.       m - bit of minute (0-59)
  2413.       x - bit of 2 second increment
  2414.  
  2415.  
  2416.  
  2417. Find may generate the following errors.
  2418.  
  2419.         Error Class ERRDOS
  2420.  
  2421.           ERRnofiles
  2422.           ERRbadpath
  2423.           ERRnoaccess
  2424.           ERRbadaccess
  2425.           ERRbadshare
  2426.           <implementation specific>
  2427.  
  2428.  
  2429.         Error Class ERRSRV
  2430.  
  2431.           ERRerror
  2432.           ERRaccess
  2433.           ERRinvnid
  2434.           <implementation specific>
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446. SMB Protocol Extensions    - 38 -           November 7, 1988
  2447.  
  2448.  
  2449.  
  2450.         Error Class ERRHRD
  2451.  
  2452.           <implementation specific>
  2453.  
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477.  
  2478.  
  2479.  
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512. SMB Protocol Extensions    - 39 -           November 7, 1988
  2513.  
  2514.  
  2515. 9.2.4.  FIND CLOSE
  2516.  
  2517. Request Format: (same as core Search Protocol - "Find  Next"
  2518. form)
  2519.  
  2520.   BYTE   smb_wct;            /* value = 2 */
  2521.   WORD   smb_count;          /* max number of entries to find */
  2522.   WORD   smb_attr;           /* search attribute */
  2523.   WORD   smb_bcc;            /* minimum value = 5 */
  2524.   BYTE   smb_ident1;         /* ASCII  (04) */
  2525.   BYTE   smb_pathname[];     /* null (may contain only null) */
  2526.   BYTE   smb_ident2;         /* Variable Block (05) */
  2527.   WORD   smb_keylen;         /* resume (close) key length (may not be zero) */
  2528.   BYTE   smb_resumekey[*];   /* "Find Close" key (* = value of smb_keylen) */
  2529.  
  2530.  
  2531.  
  2532. Response Format: (same format as core Search Protocol)
  2533.  
  2534.   BYTE   smb_wct;        /* value = 1 */
  2535.   WORD   smb_reserved;   /* reserved */
  2536.   WORD   smb_bcc;        /* value = 3 */
  2537.   BYTE   smb_ident;      /* Variable Block (05) */
  2538.   WORD   smb_datalen;    /* data length (value = 0) */
  2539.  
  2540.  
  2541.  
  2542.  
  2543. The resume_key (or close key) has the following format:
  2544.  
  2545.   BYTE   sr_res;         /* reserved:
  2546.                            bit    7 - reserved for consumer use
  2547.                            bit  5,6 - reserved for system use (must be preserved)
  2548.                            bits 0-4 - rsvd for server (must be preserved by consumer) */
  2549.   BYTE   sr_name[11];    /* pathname sought.  Format:
  2550.                            1-8 character file name, left justified
  2551.                            0-3 character extension, left justified (in last 3 chars) */
  2552.   BYTE   sr_findid[1];   /* uniquely identifies find through find close */
  2553.   BYTE   sr_server[4];   /* available for server use (must be non-zero) */
  2554.   BYTE   sr_res[4];      /* reserved for consumer use */
  2555.  
  2556.  
  2557.  
  2558.  
  2559. Service:
  2560.  
  2561. The Find Close protocol closes  the  association  between  a
  2562. Find  id  returned  (in the resume_key) by the Find protocol
  2563. and the directory search.
  2564.  
  2565. Whereas the First Find protocol logically opens  the  direc-
  2566. tory,  subsequent  find  protocols  presenting  a resume_key
  2567. further  "read"  the  directory,  the  Find  Close  protocol
  2568. "closes"  the  directory  allowing  the  server  to free any
  2569.  
  2570.  
  2571.  
  2572. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578. SMB Protocol Extensions    - 40 -           November 7, 1988
  2579.  
  2580.  
  2581. resources held in support of the directory search.
  2582.  
  2583. The Find Close protocol is used to match the find Close OS/2
  2584. system  call.  The protocols "Find", "Find Unique" and "Find
  2585. Close" are methods of reading (or  searching)  a  directory.
  2586. These  protocols  may  be used in place of the core "Search"
  2587. protocol when LANMAN 1.0 dialect has been negotiated.  There
  2588. may be cases where the Search protocol will still be used.
  2589.  
  2590. Although only the find id portion the resume key  should  be
  2591. required to identify the search being terminated, the entire
  2592. resume_key as returned in the previous Find (either a  "Find
  2593. First"  or "Find Next") is sent to the server in this proto-
  2594. col.
  2595.  
  2596.  
  2597. Find Close may generate the following errors.
  2598.  
  2599.         Error Class ERRDOS
  2600.  
  2601.           ERRbadfid
  2602.           <implementation specific>
  2603.  
  2604.  
  2605.         Error Class ERRSRV
  2606.  
  2607.           ERRerror
  2608.           ERRinvnid
  2609.           <implementation specific>
  2610.  
  2611.  
  2612.         Error Class ERRHRD
  2613.  
  2614.           <implementation specific>
  2615.  
  2616.  
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644. SMB Protocol Extensions    - 41 -           November 7, 1988
  2645.  
  2646.  
  2647. 9.2.5.  FIND UNIQUE
  2648.  
  2649. Request Format: (same as core Search Protocol - "Find First"
  2650. form)
  2651.  
  2652.   BYTE   smb_wct;          /* value = 2 */
  2653.   WORD   smb_count;        /* max number of entries to find */
  2654.   WORD   smb_attr;         /* search attribute */
  2655.   WORD   smb_bcc;          /* minimum value = 5 */
  2656.   BYTE   smb_ident1;       /* ASCII  (04) */
  2657.   BYTE   smb_pathname[];   /* filename (may contain global characters) */
  2658.   BYTE   smb_ident2;       /* Variable Block (05) */
  2659.   WORD   smb_keylen;       /* must be zero ("Find First" only) */
  2660.  
  2661.  
  2662.  
  2663. Response Format: (same as core Search Protocol)
  2664.  
  2665.   BYTE   smb_wct;       /* value = 1 */
  2666.   WORD   smb_count;     /* number of entries found */
  2667.   WORD   smb_bcc;       /* minimum value = 3 */
  2668.   BYTE   smb_ident;     /* Variable Block (05) */
  2669.   WORD   smb_datalen;   /* data length */
  2670.   BYTE   smb_data[*];   /* directory entries */
  2671.  
  2672.  
  2673.  
  2674. Directory Information Entry (dir_info) Format: (same as core
  2675. Search Protocol)
  2676.  
  2677.   BYTE   find_buf_reserved[21];   /* reserved (resume_key) */
  2678.   BYTE   find_buf_attr;           /* attribute */
  2679.   WORD   find_buf_time;           /* modification time (hhhhh mmmmmm xxxxx)
  2680.                                   where 'xxxxx' is in two second increments */
  2681.   WORD   find_buf_date;           /* modification date (yyyyyyy mmmm ddddd) */
  2682.  DWORD   find_buf_size;           /* file size */
  2683.   BYTE   find_buf_pname[13];      /* file name -- ASCII (null terminated) */
  2684.  
  2685.  
  2686.  
  2687. The resume_key has the following format:
  2688.  
  2689.   BYTE   sr_res;         /* reserved:
  2690.                            bit    7 - reserved for consumer use
  2691.                            bit  5,6 - reserved for system use (must be preserved)
  2692.                            bits 0-4 - rsvd for server (must be preserved by consumer) */
  2693.   BYTE   sr_name[11];    /* pathname sought.  Format:
  2694.                            1-8 character file name, left justified
  2695.                            0-3 character extension, left justified (in last 3 chars) */
  2696.   BYTE   sr_findid[1];   /* uniquely identifies find through find close */
  2697.   BYTE   sr_server[4];   /* available for server use (must be non-zero) */
  2698.   BYTE   sr_res[4];      /* reserved for consumer use */
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710. SMB Protocol Extensions    - 42 -           November 7, 1988
  2711.  
  2712.  
  2713. Service:
  2714.  
  2715. The Find Unique protocol finds the directory entry or  group
  2716. of  entries  matching  the  specified  file  pathname.   The
  2717. filename portion of the pathname may  contain  global  (wild
  2718. card)  characters,  but the search may not be resumed and no
  2719. Find Close protocol is expected.
  2720.  
  2721. The protocols "Find ", "Find Unique" and  "Find  Close"  are
  2722. methods of reading (or searching) a directory.  These proto-
  2723. cols may be used in place of the core "Search" protocol when
  2724. LANMAN  1.0 dialect has been negotiated.  There may be cases
  2725. where the Search protocol will still be used.
  2726.  
  2727. The format of the Find Unique protocol is the  same  as  the
  2728. core  "Search"  protocol.  The difference is that the direc-
  2729. tory is logically opened , any  matching  entries  returned,
  2730. and then the directory is logically closed.
  2731.  
  2732. This allows the Server to make better use of its  resources.
  2733. No Search buffers are held (search resumption via presenting
  2734. a "resume_key" will not be allowed).
  2735.  
  2736. Only one buffer of entries is expected and find  close  need
  2737. not be sent).
  2738.  
  2739. The file path name in the request specifies the file  to  be
  2740. sought.   The  attribute field indicates the attributes that
  2741. the file must have.  If the attribute is zero then only nor-
  2742. mal  files  are  returned.   If  the  system file, hidden or
  2743. directory  attributes  are  specified  then  the  search  is
  2744. inclusive  -- both the specified type(s) of files and normal
  2745. files are returned.  If the volume label attribute is speci-
  2746. fied then the search is exclusive, and only the volume label
  2747. entry is returned
  2748.  
  2749. The  max-count  field  specifies  the  number  of  directory
  2750. entries  to  be returned.  The response will contain zero or
  2751. more directory entries as determined by  the  count-returned
  2752. field.   No  more  than  max-count entries will be returned.
  2753. Only entries that match the sought  filename/attribute  will
  2754. be returned.
  2755.  
  2756. The resume_key field must be null (length = 0).
  2757.  
  2758. A  Find  Unique  request  will  terminate  when  either  the
  2759. requested  maximum  number  of  entries that match the named
  2760. file are found, or the end of directory is  reached  without
  2761. the  maximum number of matches being found.  A response con-
  2762. taining no entries indicates that no matching  entries  were
  2763. found  between  the starting point of the search and the end
  2764. of directory.
  2765.  
  2766. There may be multiple matching  entries  in  response  to  a
  2767.  
  2768.  
  2769.  
  2770. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776. SMB Protocol Extensions    - 43 -           November 7, 1988
  2777.  
  2778.  
  2779. single  request  as Find Unique supports "wild cards" in the
  2780. file name (last component of the pathname). "?" is the  wild
  2781. card  for  single  characters,  "*" or "null" will match any
  2782. number of filename characters within a single  part  of  the
  2783. filename  component.  The filename is divided into two parts
  2784. -- an eight character name and a three character  extension.
  2785. The name and extension are divided by a ".".
  2786.  
  2787. If a filename part commences with  one  or  more  "?"s  then
  2788. exactly  that  number  of  characters will be matched by the
  2789. Wild Cards, e.g., "??x" will equal "abx" but not  "abcx"  or
  2790. "ax".   When  a filename part has trailing "?"s then it will
  2791. match the specified number  of  characters  or  less,  e.g.,
  2792. "x??"  will  match  "xab", "xa" and "x", but not "xabc".  If
  2793. only "?"s are present in the filename part, then it is  han-
  2794. dled as for trailing "?"s
  2795.  
  2796. "*" or "null" match entire pathname parts, thus  "*.abc"  or
  2797. ".abc"  will  match  any  file  with  an extension of "abc".
  2798. "*.*", "*" or "null" will match all files in a directory.
  2799.  
  2800. Unprotected servers require the requester to have read  per-
  2801. mission  on  the  subtree  containing the directory searched
  2802. (the share specifies read permission).
  2803.  
  2804. Protected servers require the requester to  have  permission
  2805. to search the specified directory.
  2806.  
  2807. If a Find Unique requests more data than can be placed in  a
  2808. message  of  the  max-xmit-size  for  the TID specified, the
  2809. server will abort the virtual circuit to the consumer.
  2810.  
  2811. The number of entries returned will be the minimum of:
  2812.  
  2813.         1. The number of entries requested.
  2814.         2. The number of (complete) entries that will fit in the negotiated SMB buffer.
  2815.         3. The number of entries that match the requested name pattern and attributes.
  2816.  
  2817.  
  2818. The error ERRnofiles set in smb_err field  of  the  response
  2819. header  or  a  zero value in smb_count of the response indi-
  2820. cates no matching entry was found.
  2821.  
  2822. The resume search key returned  along  with  each  directory
  2823. entry  is a server defined key. This key will be returned as
  2824. in the Find protocol and Search protocol however it may  NOT
  2825. be returned to continue the search.
  2826.  
  2827.  
  2828.  
  2829.  
  2830. The date is in the following format:
  2831.   bits:
  2832.        1111 11
  2833.  
  2834.  
  2835.  
  2836. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842. SMB Protocol Extensions    - 44 -           November 7, 1988
  2843.  
  2844.  
  2845.        5432 1098 7654 3210
  2846.        yyyy yyym mmmd dddd
  2847. where:
  2848.       y - bit of year 0-119 (1980-2099)
  2849.       m - bit of month 1-12
  2850.       d - bit of day 1-31
  2851.  
  2852.  
  2853.  
  2854. The time is in the following format:
  2855.   bits:
  2856.        1111 11
  2857.        5432 1098 7654 3210
  2858.        hhhh hmmm mmmx xxxx
  2859. where:
  2860.       h - bit of hour (0-23)
  2861.       m - bit of minute (0-59)
  2862.       x - bit of 2 second increment
  2863.  
  2864.  
  2865.  
  2866. Find Unique may generate the following errors.
  2867.  
  2868.         Error Class ERRDOS
  2869.  
  2870.           ERRnofiles
  2871.           ERRbadpath
  2872.           ERRnoaccess
  2873.           ERRbadaccess
  2874.           ERRbadshare
  2875.           <implementation specific>
  2876.  
  2877.  
  2878.         Error Class ERRSRV
  2879.  
  2880.           ERRerror
  2881.           ERRaccess
  2882.           ERRinvnid
  2883.           <implementation specific>
  2884.  
  2885.  
  2886.         Error Class ERRHRD
  2887.  
  2888.           <implementation specific>
  2889.  
  2890.  
  2891.  
  2892.  
  2893.  
  2894.  
  2895.  
  2896.  
  2897.  
  2898.  
  2899.  
  2900.  
  2901.  
  2902. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908. SMB Protocol Extensions    - 45 -           November 7, 1988
  2909.  
  2910.  
  2911. 9.2.6.  GET EXPANDED FILE ATTRIBUTES
  2912.  
  2913. Request Format:
  2914.  
  2915.   BYTE   smb_wct;   /* value = 1 */
  2916.   WORD   smb_fid;   /* file handle */
  2917.   WORD   smb_bcc;   /* value = 0 */
  2918.  
  2919.  
  2920. Response Format:
  2921.  
  2922.   BYTE   smb_wct;         /* value = 11 */
  2923.   WORD   smb_cdate;       /* date of creation */
  2924.   WORD   smb_ctime;       /* time of creation */
  2925.   WORD   smb_adate;       /* date of last access */
  2926.   WORD   smb_atime;       /* time of last access */
  2927.   WORD   smb_mdate;       /* date of last modification */
  2928.   WORD   smb_mtime;       /* time of last modification */
  2929.  DWORD   smb_datasize;    /* file end of data */
  2930.  DWORD   smb_allocsize;   /* file allocation */
  2931.   WORD   smb_attr;        /* file attribute */
  2932.   WORD   smb_bcc;         /* minimum value = 0 */
  2933.   BYTE   smb_rsvd[];      /* reserved */
  2934.  
  2935.  
  2936.  
  2937. Service Enhancement:
  2938.  
  2939. The Expanded Get File Attributes is enhanced to return  more
  2940. information  about  the queried file.  The current values of
  2941. the file attributes listed as output parameters are returned
  2942. to  the  requester.  If a server does not support one of the
  2943. optional attributes, a null value (hex FFFF) is returned.
  2944.  
  2945. The file being interrogated is specified by the file  handle
  2946. (FID).
  2947.  
  2948.  
  2949. The values of the response fields which are for  information
  2950. not requested (via smb_info of the request) are undefined.
  2951.  
  2952.  
  2953. The attribute field  (smb_attr)  has  the  following  format
  2954. (bit0  is  the  least  significant bit).  This field matches
  2955. that used by OS/2.
  2956.  
  2957.         bit0 - read only file
  2958.         bit1 - "hidden" file
  2959.         bit2 - system file
  2960.         bit3 - reserved
  2961.         bit4 - directory
  2962.         bit5  - archive file
  2963.         bits6-15 - reserved (must be zero)
  2964.  
  2965.  
  2966.  
  2967.  
  2968. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974. SMB Protocol Extensions    - 46 -           November 7, 1988
  2975.  
  2976.  
  2977. Note that the volume label bit (as defined in the core  pro-
  2978. tocol)  is no longer a valid attribute.  The volume label is
  2979. now returned in the Query Server Information response.
  2980.  
  2981. The contents of response parameters is not guaranteed in the
  2982. case of an error return (any protocol response with an error
  2983. set in the header may have smb_wct of zero and smb_bcc count
  2984. of zero).
  2985.  
  2986.  
  2987.  
  2988. The dates are in the following format:
  2989.   bits:
  2990.        1111 11
  2991.        5432 1098 7654 3210
  2992.        yyyy yyym mmmd dddd
  2993. where:
  2994.       y - bit of year 0-119 (1980-2099)
  2995.       m - bit of month 1-12
  2996.       d - bit of day 1-31
  2997.  
  2998.  
  2999.  
  3000. The times are in the following format:
  3001.   bits:
  3002.        1111 11
  3003.        5432 1098 7654 3210
  3004.        hhhh hmmm mmmx xxxx
  3005. where:
  3006.       h - bit of hour (0-23)
  3007.       m - bit of minute (0-59)
  3008.       x - bit of 2 second increment
  3009.  
  3010.  
  3011.  
  3012. Get Expanded file  attributes  may  generate  the  following
  3013. errors.
  3014.  
  3015.         Error Class ERRDOS
  3016.  
  3017.           ERRbadfile
  3018.           ERRbadfid
  3019.           <implementation specific>
  3020.  
  3021.  
  3022.         Error Class ERRSRV
  3023.  
  3024.           ERRerror
  3025.           ERRinvnid
  3026.           <implementation specific>
  3027.  
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033.  
  3034. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040. SMB Protocol Extensions    - 47 -           November 7, 1988
  3041.  
  3042.  
  3043.  
  3044.         Error Class ERRHRD
  3045.  
  3046.           <implementation specific>
  3047.  
  3048.  
  3049.  
  3050.  
  3051.  
  3052.  
  3053.  
  3054.  
  3055.  
  3056.  
  3057.  
  3058.  
  3059.  
  3060.  
  3061.  
  3062.  
  3063.  
  3064.  
  3065.  
  3066.  
  3067.  
  3068.  
  3069.  
  3070.  
  3071.  
  3072.  
  3073.  
  3074.  
  3075.  
  3076.  
  3077.  
  3078.  
  3079.  
  3080.  
  3081.  
  3082.  
  3083.  
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089.  
  3090.  
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.  
  3100. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106. SMB Protocol Extensions    - 48 -           November 7, 1988
  3107.  
  3108.  
  3109. 9.2.7.  IOCTL
  3110.  
  3111. Primary Request Format:
  3112.  
  3113.  
  3114.   BYTE   smb_wct;        /* value = 14 */
  3115.   WORD   smb_fid;        /* file handle */
  3116.   WORD   smb_cat;        /* device category */
  3117.   WORD   smb_fun;        /* device function */
  3118.   WORD   smb_tpscnt;     /* total number of parameter bytes being sent */
  3119.   WORD   smb_tdscnt;     /* total number of data bytes being sent */
  3120.   WORD   smb_mprcnt;     /* max number of parameter bytes to return */
  3121.   WORD   smb_mdrcnt;     /* max number of data bytes to return */
  3122.  DWORD   smb_timeout;    /* number of milliseconds to wait for completion */
  3123.   WORD   smb_rsvd;       /* reserved */
  3124.   WORD   smb_pscnt;      /* number of parameter bytes being sent this buffer */
  3125.   WORD   smb_psoff;      /* offset (from start of SMB hdr) to parameter bytes */
  3126.   WORD   smb_dscnt;      /* number of data bytes being sent this buffer */
  3127.   WORD   smb_dsoff;      /* offset (from start of SMB hdr) to data bytes */
  3128.   WORD   smb_bcc;        /* total bytes (including pad bytes) following */
  3129.   BYTE   smb_pad[];      /* (optional) to pad to word or dword boundary */
  3130.   BYTE   smb_param[*];   /* param bytes (* = value of smb_pscnt) */
  3131.   BYTE   smb_pad1[];     /* (optional) to pad to word or dword boundary */
  3132.   BYTE   smb_data[*];    /* data bytes (* = value of smb_dscnt) */
  3133.  
  3134.  
  3135.  
  3136. Interim Response Format (if no error  -  ok  send  remaining
  3137. data):
  3138.  
  3139.   BYTE   smb_wct;   /* value = 0 */
  3140.   WORD   smb_bcc;   /* value = 0 */
  3141.  
  3142.  
  3143. Secondary Request Format (more data - may be zero or more of
  3144. these):
  3145.  
  3146.   BYTE   smb_wct;        /* value = 8 */
  3147.   WORD   smb_tpscnt;     /* total number of parameter bytes being sent */
  3148.   WORD   smb_tdscnt;     /* total number of data bytes being sent */
  3149.   WORD   smb_pscnt;      /* number of parameter bytes being sent this buffer */
  3150.   WORD   smb_psoff;      /* offset (from start of SMB hdr) to parameter bytes */
  3151.   WORD   smb_psdisp;     /* byte displacement for these parameter bytes */
  3152.   WORD   smb_dscnt;      /* number of data bytes being sent this buffer */
  3153.   WORD   smb_dsoff;      /* offset (from start of SMB hdr) to data bytes */
  3154.   WORD   smb_dsdisp;     /* byte displacement for these data bytes */
  3155.   WORD   smb_bcc;        /* total bytes (including pad bytes) following */
  3156.   BYTE   smb_pad[];      /* (optional) to pad to word or dword boundary */
  3157.   BYTE   smb_param[*];   /* param bytes (* = value of smb_pscnt) */
  3158.   BYTE   smb_pad1[];     /* (optional) to pad to word or dword boundary */
  3159.   BYTE   smb_data[*];    /* data bytes (* = value of smb_dscnt) */
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172. SMB Protocol Extensions    - 49 -           November 7, 1988
  3173.  
  3174.  
  3175. Response Format (may respond with one or more of these):
  3176.  
  3177.   BYTE   smb_wct;        /* value = 8 */
  3178.   WORD   smb_tprcnt;     /* total number of parameter bytes being returned */
  3179.   WORD   smb_tdrcnt;     /* total number of data bytes being returned */
  3180.   WORD   smb_prcnt;      /* number of param bytes being returned this buffer */
  3181.   WORD   smb_proff;      /* offset (from start of SMB hdr) to parameter bytes */
  3182.   WORD   smb_prdisp;     /* byte displacement for these parameter bytes */
  3183.   WORD   smb_drcnt;      /* number of data bytes being returned this buffer */
  3184.   WORD   smb_droff;      /* offset (from start of SMB hdr) to data bytes */
  3185.   WORD   smb_drdisp;     /* byte displacement for these data bytes */
  3186.   WORD   smb_bcc;        /* total bytes (including pad bytes) following */
  3187.   BYTE   smb_pad[];      /* (optional) to pad to word or dword boundary */
  3188.   BYTE   smb_param[*];   /* param bytes (* = value of smb_prcnt) */
  3189.   BYTE   smb_pad1[];     /* (optional) to pad to word or dword boundary */
  3190.   BYTE   smb_data[*];    /* data bytes (* = value of smb_drcnt) */
  3191.  
  3192. Service:
  3193.  
  3194. This function delivers a device/file specific request  to  a
  3195. server, and the device/file specific response to the reques-
  3196. ter.  The target file is identified by the  file  handle  in
  3197. smb_fid.
  3198.  
  3199. The request defines a function specific to a particular dev-
  3200. ice  type  on a particular server type.  Therefore the func-
  3201. tions supported are not defined  by  the  protocol,  but  by
  3202. consumer/server  implementations.   The protocol simply pro-
  3203. vides a means of delivering them and retrieving the results.
  3204.  
  3205. Note that the primary request  through  the  final  response
  3206. make  up  the  complete protocol, thus the TID, PID, UID and
  3207. MID are expected to remain constant and can be used by  both
  3208. the  server and consumer to route the individual messages of
  3209. the protocol to the correct process.
  3210.  
  3211. The number of bytes needed in order  to  perform  the  IOCTL
  3212. request may be more than will fit in a single buffer.
  3213.  
  3214. At the time of the request, the consumer knows the number of
  3215. parameter and data bytes expected to be sent and passes this
  3216. information  to  the  server   via   the   primary   request
  3217. (smb_tpscnt and smb_tdscnt). This may be reduced by lowering
  3218. the  total  number  of  bytes  expected  (smb_tpscnt  and/or
  3219. smbtdscnt) in each (any) secondary request.
  3220.  
  3221. Thus when the amount of parameter bytes received  (total  of
  3222. each  smb_pscnt)  equals the total amount of parameter bytes
  3223. expected (smallest smb_tpscnt) received, then the server has
  3224. received all the parameter bytes.
  3225.  
  3226. Likewise, when the amount of data bytes received  (total  of
  3227. each  smb_dscnt)  equals  the  total  amount  of  data bytes
  3228. expected (smallest smb_tdscnt) received, then the server has
  3229.  
  3230.  
  3231.  
  3232. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238. SMB Protocol Extensions    - 50 -           November 7, 1988
  3239.  
  3240.  
  3241. received all the data bytes.
  3242.  
  3243. The parameter bytes should normally be sent  first  followed
  3244. by  the  data  bytes.  However,  the server knows where each
  3245. begins  and  ends  in  each  buffer  by  the  offset  fields
  3246. (smb_psoff  and  smb_dsoff) and the length fields (smb_pscnt
  3247. and smb_dscnt).  The displacement of the bytes (relative  to
  3248. start  of  each)  is also known (smb_psdisp and smb_dsdisp).
  3249. Thus the server is able to reasemble the parameter and  data
  3250. bytes  should  the  "packets"  (buffers)  be received out of
  3251. sequence.
  3252.  
  3253. If all parameter bytes and data  bytes  fit  into  a  single
  3254. buffer, then no interrum response is expected (and no secon-
  3255. dary request is sent).
  3256.  
  3257. The Consumer knows the maximum  amount  of  data  bytes  and
  3258. parameter bytes which the server may return (from smb_mprcnt
  3259. and smb_mdrcnt of the request).   Thus  it  initializes  its
  3260. bytes  expected  variables to these values.  The Server then
  3261. informs the consumer of the actual  amounts  being  returned
  3262. via  each  "packet" (buffer) of the response (smb_tprcnt and
  3263. smb_tdrcnt).
  3264.  
  3265. The server may reduce the expected  bytes  by  lowering  the
  3266. total   number   of   bytes   expected   (smb_tprcnt  and/or
  3267. smb_tdrcnt) in each (any) response.
  3268.  
  3269. Thus when the amount of parameter bytes received  (total  of
  3270. each  smb_prcnt)  equals the total amount of parameter bytes
  3271. expected (smallest smb_tprcnt) received, then  the  consumer
  3272. has received all the parameter bytes.
  3273.  
  3274. Likewise, when the amount of data bytes received  (total  of
  3275. each  smb_drcnt)  equals  the  total  amount  of  data bytes
  3276. expected (smallest smb_tdrcnt) received, then  the  consumer
  3277. has received all the data bytes.
  3278.  
  3279. The parameter bytes should normally be returned  first  fol-
  3280. lowed  by  the data bytes. However, the consumer knows where
  3281. each begins and ends in each buffer  by  the  offset  fields
  3282. (smb_proff  and  smb_droff) and the length fields (smb_prcnt
  3283. and smb_drcnt).  The displacement of the bytes (relative  to
  3284. start  of  each)  is also known (smb_prdisp and smb_drdisp).
  3285. Thus the consumer is able to  reasemble  the  parameter  and
  3286. data bytes should the "packets" (buffers) be received out of
  3287. sequence.
  3288.  
  3289. In the simplest form, a single request is sent and a  single
  3290. response is returned.
  3291.  
  3292. Thus the flow is:
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304. SMB Protocol Extensions    - 51 -           November 7, 1988
  3305.  
  3306.  
  3307. 1    The consumer sends the first  (primary)  request  which
  3308.      identifies  the  total bytes (both parameters and data)
  3309.      which are expected to be sent and contains as  many  of
  3310.      those  bytes  as  will fit in a negotiated size buffer.
  3311.      This request also  identifies  the  maximum  number  of
  3312.      bytes  (both  parameters and data) the server will need
  3313.      to return on IOCTL completion. If all the bytes fit  in
  3314.      the single buffer, skip to step 4.
  3315.  
  3316.  
  3317. 2    The server responds  with  a  single  interim  response
  3318.      meaning "ok, send the remainder of the bytes".
  3319.  
  3320.  
  3321. 3    The consumer then sends another buffer full of bytes to
  3322.      the   server.  On  each  iteration  of  this  secondary
  3323.      request, smb_tpscnt and/or smb_tdscnt could be reduced.
  3324.      This  step  is  repeated  until  all  bytes  have  been
  3325.      delivered to the server (total of all smb_pscnt  equals
  3326.      smallest  smb_tpscnt  and total of all smb_dscnt equals
  3327.      smallest smb_tdscnt).
  3328.  
  3329.  
  3330. 4    The Server sets up and  performs  the  IOCTL  with  the
  3331.      information provided.
  3332.  
  3333.  
  3334. 5    Upon completion of the IOCTL, the server sends back (up
  3335.      to)  the  number  of parameter and data bytes requested
  3336.      (or as many as will fit in the negotiated buffer size).
  3337.      This  step is repeated until all result bytes have been
  3338.      returned.   On  each  iteration   of   this   response,
  3339.      smb_tprcnt  and/or  smb_tdrcnt  could be reduced.  This
  3340.      step is repeated until all bytes have been delivered to
  3341.      the  consumer  (total  of all smb_prcnt equals smallest
  3342.      smb_tprcnt and total of all smb_drcnt  equals  smallest
  3343.      smb_tdrcnt).
  3344.  
  3345.  
  3346.  
  3347. The flow for the IOCTL protocol when the request  parameters
  3348. and data does NOT all fit in a single buffer is:
  3349.  
  3350.      consumer ----> IOCTL request (data) >-----> server
  3351.      consumer <--< OK send remaining data <----  server
  3352.      consume> IOCTL secondary request 1 (data) > server
  3353.      consume> IOCTL secondary request 2 (data) > server
  3354.      .                       .                        .
  3355.      consume> IOCTL secondary request n (data) > server
  3356.      .                       .                        .
  3357.      .    (server sets up and performs the IOCTL)     .
  3358.      .                       .                        .
  3359.      consumer <-< IOCTL response 1 (data) <----- server
  3360.      consumer <-< IOCTL response 2 (data) <----- server
  3361.  
  3362.  
  3363.  
  3364. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370. SMB Protocol Extensions    - 52 -           November 7, 1988
  3371.  
  3372.  
  3373.      .                       .                        .
  3374.      consumer <-< IOCTL response n (data) <----- server
  3375.  
  3376. The flow for the IOCTL protocol when the request  parameters
  3377. and data does all fit in a single buffer is:
  3378.  
  3379.      consumer ----> IOCTL request (data) >-----> server
  3380.      .                       .                        .
  3381.      .    (server sets up and performs the IOCTL)     .
  3382.      .                       .                        .
  3383.      consumer <-< IOCTL response 1 (data) <----- server
  3384.      .      (only one if all data fit in buffer)      .
  3385.      consumer <-< IOCTL response 2 (data) <----- server
  3386.      .                       .                        .
  3387.      consumer <-< IOCTL response n (data) <----- server
  3388.  
  3389.  
  3390. The first release of LANMAN 1.0 will support only  the  most
  3391. simple  form  of  the IOCTL protocol.  Only a single request
  3392. and a single response  is  expected.   Further  the  maximum
  3393. number  of  parameter  bytes is limited to 128 bytes and the
  3394. maximum number of data bytes is limited to 128 bytes on both
  3395. the  request and response IOCTL protocols. This ensures that
  3396. the request and response will fit within  the  minimum  1024
  3397. byte SMB buffers.
  3398.  
  3399. The flow for the IOCTL protocol when the request  parameters
  3400. and  data  does  all fit in a single buffer is and the reply
  3401. parameters and data all fit in a single buffer is:
  3402.  
  3403.      consumer ----> IOCTL request (data) >-----> server
  3404.      .                       .                        .
  3405.      .    (server sets up and performs the IOCTL)     .
  3406.      .                       .                        .
  3407.      consumer <--< IOCTL response (data) <------ server
  3408.  
  3409.  
  3410. IOCTL may generate the following errors.
  3411.  
  3412.         Error Class ERRDOS
  3413.  
  3414.           ERRbadfile
  3415.           ERRbadfid
  3416.           ERRbaddata
  3417.           <implementation specific>
  3418.  
  3419.  
  3420.         Error Class ERRSRV
  3421.  
  3422.           ERRerror
  3423.           ERRinvnid
  3424.           <implementation specific>
  3425.  
  3426.  
  3427.  
  3428.  
  3429.  
  3430. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436. SMB Protocol Extensions    - 53 -           November 7, 1988
  3437.  
  3438.  
  3439.  
  3440.         Error Class ERRHRD
  3441.  
  3442.           <implementation specific>
  3443.  
  3444.  
  3445.  
  3446.  
  3447.  
  3448.  
  3449.  
  3450.  
  3451.  
  3452.  
  3453.  
  3454.  
  3455.  
  3456.  
  3457.  
  3458.  
  3459.  
  3460.  
  3461.  
  3462.  
  3463.  
  3464.  
  3465.  
  3466.  
  3467.  
  3468.  
  3469.  
  3470.  
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476.  
  3477.  
  3478.  
  3479.  
  3480.  
  3481.  
  3482.  
  3483.  
  3484.  
  3485.  
  3486.  
  3487.  
  3488.  
  3489.  
  3490.  
  3491.  
  3492.  
  3493.  
  3494.  
  3495.  
  3496. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502. SMB Protocol Extensions    - 54 -           November 7, 1988
  3503.  
  3504.  
  3505. 9.2.8.  LOCK and READ
  3506.  
  3507. Request Format (same as core READ):
  3508.  
  3509.   BYTE   smb_wct;      /* value = 5 */
  3510.   WORD   smb_fid;      /* file handle */
  3511.   WORD   smb_count;    /* number of bytes to lock and return */
  3512.  DWORD   smb_offset;   /* offset in file to lock and begin read */
  3513.   WORD   smb_remcnt;   /* number of bytes remaining to be read */
  3514.   WORD   smb_bcc;      /* value = 0 */
  3515.  
  3516.  
  3517.  
  3518. Response Format (same as core READ):
  3519.  
  3520.   BYTE   smb_wct;       /* value = 5 */
  3521.   WORD   smb_count;     /* number of locked bytes read */
  3522.   WORD   smb_rsvd[4];   /* reserved (to match size of write request) */
  3523.   WORD   smb_bcc;       /* minimum value = 4 */
  3524.   BYTE   smb_ident1;    /* value = DATA_BLOCK */
  3525.   WORD   smb_size;      /* length of data returned */
  3526.   BYTE   smb_data[];    /* data */
  3527.  
  3528.  
  3529. Service:
  3530.  
  3531. The LockandRead request is used to lock and "read ahead" the
  3532. specified bytes.
  3533.  
  3534. The locked portion of a file is "safe" to read ahead because
  3535. no other process can access the locked bytes until this pro-
  3536. cess unlocks the bytes.  Thus the consumer can  assume  that
  3537. the bytes being locked will be read and submit this protocol
  3538. to both lock and read ahead the bytes.
  3539.  
  3540. This can provide  significant  performance  improvements  on
  3541. data  base  update  operations  (lock  data  -> read data ->
  3542. [update -> write data] -> unlock data).
  3543.  
  3544. Whether or not this protocol is supported (along  with  Wri-
  3545. teandUnlock)  is  returned in the smb_flg field of the nego-
  3546. tiate response.
  3547.  
  3548. The request and response format are identical  to  the  core
  3549. read.   The  server  merely  locks  the bytes before reading
  3550. them.
  3551.  
  3552. If an error occurs on the lock,  the  bytes  should  not  be
  3553. read.
  3554.  
  3555. LockandRead may generate the following errors:
  3556.  
  3557.  
  3558.  
  3559.  
  3560.  
  3561.  
  3562. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568. SMB Protocol Extensions    - 55 -           November 7, 1988
  3569.  
  3570.  
  3571.  
  3572.         Error Class ERRDOS:
  3573.  
  3574.           ERRnoaccess
  3575.           ERRbadfid
  3576.           ERRlock
  3577.           ERRbadaccess
  3578.  
  3579.  
  3580.         Error Class ERRSRV:
  3581.  
  3582.           ERRerror
  3583.           ERRinvdevice
  3584.           ERRinvnid
  3585.           <implementation specific>
  3586.  
  3587.  
  3588.         Error Class ERRHRD:
  3589.  
  3590.           <implementation specific>
  3591.  
  3592.  
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.  
  3599.  
  3600.  
  3601.  
  3602.  
  3603.  
  3604.  
  3605.  
  3606.  
  3607.  
  3608.  
  3609.  
  3610.  
  3611.  
  3612.  
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.  
  3628. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634. SMB Protocol Extensions    - 56 -           November 7, 1988
  3635.  
  3636.  
  3637. 9.2.9.  LOCKING and X
  3638.  
  3639. Request Format:
  3640.  
  3641.   BYTE   smb_wct;          /* value = 8 */
  3642.   BYTE   smb_com2;         /* secondary (X) command, 0xFF = none */
  3643.   BYTE   smb_reh2;         /* reserved (must be zero) */
  3644.   WORD   smb_off2;         /* offset (from SMB hdr start) to next cmd (@smb_wct) */
  3645.   WORD   smb_fid;          /* file handle */
  3646.   WORD   smb_locktype;     /* locking mode:
  3647.                            bit 0 - 0 = lock out all access, 1 = read ok while locked
  3648.                            bit 1 - 1 = single user total file unlock
  3649.  DWORD   smb_timeout;      /* number of milliseconds to attempt each lock */
  3650.   WORD   smb_unlocknum;    /* number of unlock range structures following */
  3651.   WORD   smb_locknum;      /* number of lock range structures following */
  3652.   WORD   smb_bcc;          /* total bytes following */
  3653. struct   smb_unlkrng[*];   /* unlock range structures (* = smb_unlocknum) */
  3654. struct   smb_lockrng[*];   /* lock range structures (* = smb_locknum) */
  3655.  
  3656.  
  3657.  
  3658. Unlock Range Structure (smb_unlkrng) Format:
  3659.  
  3660.   WORD   smb_lpid;        /* pid of process "owning" the lock */
  3661.  DWORD   smb_unlockoff;   /* file offset to bytes to be unlocked */
  3662.  DWORD   smb_unlocklen;   /* number of bytes to be unlocked */
  3663.  
  3664.  
  3665.  
  3666. Lock Range Structure (smb_lockrng) Format:
  3667.  
  3668.   WORD   smb_lpid;      /* pid of process "owning" the lock */
  3669.  DWORD   smb_lockoff;   /* file offset to bytes to be locked */
  3670.  DWORD   smb_locklen;   /* number of bytes to be locked */
  3671.  
  3672.  
  3673.  
  3674. Response Format:
  3675.  
  3676.   BYTE   smb_wct;    /* value = 2 */
  3677.   BYTE   smb_com2;   /* secondary (X) command, 0xFF = none */
  3678.   BYTE   smb_res2;   /* reserved (pad to word) */
  3679.   WORD   smb_off2;   /* offset (from SMB hdr start) to next cmd (@smb_wct) */
  3680.   WORD   smb_bcc;    /* value = 0 */
  3681.  
  3682.  
  3683.  
  3684. Service Enhancement:
  3685.  
  3686. This protocol allows both locking and/or unlocking  of  file
  3687. range(s).
  3688.  
  3689.  
  3690. If unlocking  is  specified  (smb_unlocknum  non-zero),  the
  3691.  
  3692.  
  3693.  
  3694. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700. SMB Protocol Extensions    - 57 -           November 7, 1988
  3701.  
  3702.  
  3703. number  of  bytes  specified  by  smb_unlocklen  at the file
  3704. offset specified by smb_unlockoff will be unlocked for  each
  3705. unlock  range.   Then  if  locking is specified (smb_locknum
  3706. non-zero), the number of bytes specified by  smb_locklen  at
  3707. the  file offset specified by smb_lockoff will be locked for
  3708. each lock range.
  3709.  
  3710. The time specified by smb_timeout is the maximum  amount  of
  3711. time  to  wait  for  the  byte  range(s) specified to become
  3712. unlocked (so that they can be locked by this  protocol).   A
  3713. timeout  value of 0 indicates that this protocol should fail
  3714. immediately if  any  lock  range  specified  is  locked.   A
  3715. timeout value of -1 indicates that the server should wait as
  3716. long as it takes for each byte  range  specified  to  become
  3717. unlocked  so  that  it may be again locked by this protocol.
  3718. Any other value of smb_timeout specifies the maximum  number
  3719. of  milliseconds  to wait for all lock range(s) specified to
  3720. become available.
  3721.  
  3722. If any of the lock ranges timeout because of the area to  be
  3723. locked  is  already  locked  (or  the lock fails), the other
  3724. ranges in  the  protocol  request  which  were  successfully
  3725. locked as a result of this protocol will be unlocked (either
  3726. all requested ranges  will  be  locked  when  this  protocol
  3727. returns to the consumer or none).
  3728.  
  3729. If smb_locktype is 1, the lock is specified as a "read only"
  3730. lock.   Locks for both read and write (where smb_locktype is
  3731. 0) should be prohibited, but other "read only" locks  should
  3732. be  permitted.  If this mode can not be supported on a given
  3733. server, the smb_locktype field should always be treated as 0
  3734. in  that any lock attempt will fail if the byte range speci-
  3735. fied is locked.
  3736.  
  3737. Closing a file with locks still in force causes the locks to
  3738. be released in no defined order.
  3739.  
  3740. Locking is a simple mechanism for excluding other  processes
  3741. read/write  access to regions of a file.  The locked regions
  3742. can be anywhere in the logical file.   Locking  beyond  end-
  3743. of-file  is  NOT an error.  Any process using the FID speci-
  3744. fied in smb_fid  has  access  to  the  locked  bytes,  other
  3745. processes will be denied the locking of the same bytes.
  3746.  
  3747. The proper method for using locks is not to  rely  on  being
  3748. denied  read or write access on any of the read/write proto-
  3749. cols but rather to attempt the locking protocol and  proceed
  3750. with the read/write only if the lock succeeded.
  3751.  
  3752. Locking a range of bytes will fail if any subranges or over-
  3753. lapping  ranges  are  locked.  In other words, if any of the
  3754. specified bytes are already locked, the lock will fail.
  3755.  
  3756. The time which a byte range is  locked  should  be  kept  as
  3757.  
  3758.  
  3759.  
  3760. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766. SMB Protocol Extensions    - 58 -           November 7, 1988
  3767.  
  3768.  
  3769. short as possible.
  3770.  
  3771. The entire message sent and received including the  optional
  3772. second  protocol  must  fit  in  the negotiated max transfer
  3773. size.
  3774.  
  3775. NOTE - LANMAN 1.0 does not support smb_locktype where bit  1
  3776. is  set  (read  ok while locked) also smb_timeout is ignored
  3777. and treated as if it were set to zero.
  3778.  
  3779. The following are the only valid protocol requests  commands
  3780. for smb_com2 (X) for LOCKING and X:
  3781.  
  3782.         READ
  3783.         READ and X
  3784.  
  3785.  
  3786. A "single user total file lock" is also known as an  "oppor-
  3787. tunistic lock".  A consumer requests an "opportunistic lock"
  3788. by setting the appropriate bit in the  OpenX,  Open,  Create
  3789. and MakeNew protocols whenever the file is being opened in a
  3790. mode which is not exclusive.  The server responds by setting
  3791. the  appropriate  bit  in  the  response protocol indicating
  3792. whether or not the "opportunistic  lock"  was  granted.   By
  3793. granting  the  "oplock",  the server tells the consumer that
  3794. the file is currently ONLY being used by this  one  consumer
  3795. process  at  the  current  time.  The consumer can therefore
  3796. safely do read ahead and write behind as well as local cach-
  3797. ing  of  file  locks  knowing  that  the  file  will  not be
  3798. accessed/changed in any way by  another  process  while  the
  3799. "oplock" is in effect.
  3800.  
  3801. The  consumer  will  be  notified  when  any  other  process
  3802. attempts to open the "oplocked" file and if "opbatch" (bit 2
  3803. of smb_flags) was set on the  OpenX  request,  the  consumer
  3804. will  also be notified on any operation which may change the
  3805. file.
  3806.  
  3807. When another user attempts to Open (or otherwise  modify  if
  3808. "opbatch"  was  requested)  the  file  which  a consumer has
  3809. oplocked, the server will "hold off"  the  2nd  attempt  and
  3810. notify the consumer via a LockingX protocol (with bit one of
  3811. smb_locktype set) that the "oplock" is  being  broken.   The
  3812. consumer is expected to then flush any dirty buffers, submit
  3813. any file locks (LockingX protocol can be used for this)  and
  3814. respond  to the server with either a LockingX protocol (with
  3815. bit one of smb_locktype set) or with a close protocol if the
  3816. file  is  no longer in use.  Note that because a close being
  3817. sent to the server and break oplock  notification  from  the
  3818. server  could  cross  on  the  wire, if the consumer gets an
  3819. oplock notification on a file which it does not  have  open,
  3820. that  notification should be ignored.  Once the "oplock" has
  3821. been broken, the consumer must no longer do any form of data
  3822. or lock caching.  The "oplock" is never reenstated while the
  3823.  
  3824.  
  3825.  
  3826. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832. SMB Protocol Extensions    - 59 -           November 7, 1988
  3833.  
  3834.  
  3835. file is open.  If the file is still open once  the  consumer
  3836. has  been  notified,  the  2nd  opener does not get the file
  3837. "oplocked" along with the open.  If the file  is  closed  by
  3838. the  consumer which had it open, the server is again free to
  3839. grant the new opener the oplock.
  3840.  
  3841. Note that the "oplock" broken notification will only  go  to
  3842. one consumer because after the oplock is broken, any further
  3843. open attempts will just get the oplock request denied.
  3844.  
  3845. Also note that due to timing,  the  consumer  could  get  an
  3846. "oplock"  broken  notification  in a user's data buffer as a
  3847. result of this notification crossing on the wire with a Read
  3848. Raw  request.   The consumer must detect this (use length of
  3849. msg, "FFSMB", MID of -1 and   smb_cmd  of  SMBLockingX)  and
  3850. honor the "oplock" broken notification as usual.  The server
  3851. must also note on receipt of an Read Raw request that  there
  3852. is  an outstanding (unanswered) "oplock" broken notification
  3853. to the consumer and return a zero length  response  denoting
  3854. failure of the read raw request.  The consumer should (after
  3855. responding to the "oplock" broken notification), use a stan-
  3856. dard  read protocol to redo the read request.  This allows a
  3857. file to actually contain data matching  an  "oplock"  broken
  3858. notification and still be read correctly.
  3859.  
  3860. "Oplock" is a  major  performance  win  in  the  real  world
  3861. because  many  files  must be opened in a non exclusive mode
  3862. because the file could be used by  others.   However  often,
  3863. the  files  are not actually in use by multiple users at the
  3864. same instant.
  3865.  
  3866.  
  3867. Locking and X may generate the following errors.
  3868.  
  3869.         Error Class ERRDOS
  3870.  
  3871.           ERRbadfile
  3872.           ERRbadfid
  3873.           ERRlock
  3874.           <implementation specific>
  3875.  
  3876.  
  3877.         Error Class ERRSRV
  3878.  
  3879.           ERRerror
  3880.           ERRinvdevice
  3881.           ERRinvnid
  3882.           <implementation specific>
  3883.  
  3884.  
  3885.         Error Class ERRHRD
  3886.  
  3887.           <implementation specific>
  3888.  
  3889.  
  3890.  
  3891.  
  3892. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  3893.  
  3894.  
  3895.  
  3896.  
  3897.  
  3898. SMB Protocol Extensions    - 60 -           November 7, 1988
  3899.  
  3900.  
  3901. 9.2.10.  MOVE
  3902.  
  3903. Request Format:
  3904.  
  3905.   BYTE   smb_wct;          /* value = 3 */
  3906.   WORD   smb_tid2;         /* second (destination) path tid */
  3907.   WORD   smb_ofun;         /* what to do if destination file exists */
  3908.   WORD   smb_flags;        /* flags to control move operations:
  3909.                            bit 0 - destination must be a file.
  3910.                            bit 1 - destination must be a directory.
  3911.                            bit 2 - reserved (must be zero)
  3912.                            bit 3 - reserved (must be zero)
  3913.                            bit 4 - verify all writes.
  3914.   WORD   smb_bcc;          /* minimum value = 2 */
  3915.   BYTE   smb_path[];       /* pathname of source file */
  3916.   BYTE   smb_new_path[];   /* pathname of destination file */
  3917.  
  3918. Response Format:
  3919.  
  3920.   BYTE   smb_wct;         /* value = 1 */
  3921.   WORD   smb_cct;         /* number of files moved */
  3922.   WORD   smb_bcc;         /* minimum value = 0 */
  3923.   BYTE   smb_errfile[];   /* pathname of file where error occured - ASCIIZ */
  3924.  
  3925. Service:
  3926.  
  3927.  
  3928. The file  referenced  by  smb_path  (source)  is  copied  to
  3929. smb_new_path  (destination),  then  the  file  referenced by
  3930. smb_path   (source)   is   deleted.    Both   smb_path   and
  3931. smb_new_path  must refer to paths on the server.  The server
  3932. must do any necessary access permission checks on  both  the
  3933. source and the destination paths.
  3934.  
  3935. The TID in smb_tid of the  header  is  associated  with  the
  3936. source  while  smb_tid2  is associated with the destination.
  3937. These TID fields may contain the  same  or  differing  valid
  3938. TIDs.   Note  that smb_tid2 can be set to -1 indicating that
  3939. this is to be the same TID as the  TID  in  smb_tid  of  the
  3940. header.  This allows use of the move protocol with TCONandX.
  3941.  
  3942. The source path must refer to an  existing  file  or  files.
  3943. Wild  Cards  are  permitted.  Source files specified by Wild
  3944. Cards are processed until an error is  encountered.   If  an
  3945. error  is  encountered,  the  expanded  name  of the file is
  3946. returned in smb_errfile.  The  error  code  is  returned  in
  3947. smb_err.
  3948.  
  3949. The destination path can refer to either a file or a  direc-
  3950. tory.
  3951.  
  3952. The destination can be required to be a file or a  directory
  3953. by  smb_flags  bits.  If neither bit is set, the destination
  3954. may be either a file or a directory.
  3955.  
  3956.  
  3957.  
  3958. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964. SMB Protocol Extensions    - 61 -           November 7, 1988
  3965.  
  3966.  
  3967. Wild Cards are not permitted in the destination path.
  3968.  
  3969.  
  3970.  
  3971. smb_ofun bit field mapping:
  3972.   bits:
  3973.        1111 11
  3974.        5432 1098 7654 3210
  3975.        rrrr rrrr rrrr rrOO
  3976.  
  3977.   where:
  3978.        O - Open (action to  be  taken  if  destination  file
  3979. exists).
  3980.          0 - Fail.
  3981.          1 - reserved.
  3982.          2 - Truncate file.
  3983.  
  3984.        r - reserved (must be zero).
  3985.  
  3986.  
  3987.  
  3988. If target file does not exist, it will be created.  All file
  3989. components  except the last must exist (directories will not
  3990. be created).
  3991.  
  3992.  
  3993. Move may generate the following errors.
  3994.  
  3995.         Error Class ERRDOS
  3996.  
  3997.           ERRbadfile
  3998.           ERRbadpath
  3999.           ERRfileexists
  4000.           ERRnoaccess
  4001.           ERRnofiles
  4002.           ERRbadshare
  4003.           <implementation specific>
  4004.  
  4005.  
  4006.         Error Class ERRSRV
  4007.  
  4008.           ERRerror
  4009.           ERRinvnid
  4010.           ERRnosupport
  4011.           ERRaccess
  4012.           <implementation specific>
  4013.  
  4014.  
  4015.         Error Class ERRHRD
  4016.  
  4017.           <implementation specific>
  4018.  
  4019.  
  4020.  
  4021.  
  4022.  
  4023.  
  4024. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  4025.  
  4026.  
  4027.  
  4028.  
  4029.  
  4030. SMB Protocol Extensions    - 62 -           November 7, 1988
  4031.  
  4032.  
  4033. 9.2.11.  OPEN and X
  4034.  
  4035. Request Format:
  4036.  
  4037.   BYTE   smb_wct;          /* value = 15 */
  4038.   BYTE   smb_com2;         /* secondary (X) command, 0xFF = none */
  4039.   BYTE   smb_reh2;         /* reserved (must be zero) */
  4040.   WORD   smb_off2;         /* offset (from SMB hdr start) to next cmd (@smb_wct) */
  4041.   WORD   smb_flags;        /* additional information:
  4042.                            bit 0 - if set, return additional information
  4043.                            bit 1 - if set, set single user total file lock (if only access)
  4044.                            bit 2 - if set, the server should notify the consumer on any
  4045.                                    action which can modify the file (delete, setattrib,
  4046.                                    rename, etc.). if not set, the server need only notify
  4047.                                    the consumer on another open request. This bit only has
  4048.                                    meaning if bit 1 is set. */
  4049.   WORD   smb_mode;         /* file open mode */
  4050.   WORD   smb_sattr;        /* search attributes  */
  4051.   WORD   smb_attr;         /* file attributes (for create) */
  4052.  DWORD   smb_time;         /* create time */
  4053.   WORD   smb_ofun;         /* open function */
  4054.  DWORD   smb_size;         /* bytes to reserve on "create" or "truncate" */
  4055.  DWORD   smb_timeout;      /* max milliseconds to wait for resource to open */
  4056.  DWORD   smb_rsvd;         /* reserved (must be zero) */
  4057.   WORD   smb_bcc;          /* minimum value = 1 */
  4058.   BYTE   smb_pathname[];   /* file pathname */
  4059.  
  4060.  
  4061.  
  4062. Response Format:
  4063.  
  4064.   BYTE   smb_wct;         /* value = 15 */
  4065.   BYTE   smb_com2;        /* secondary (X) command, 0xFF = none */
  4066.   BYTE   smb_res2;        /* reserved (pad to word) */
  4067.   WORD   smb_off2;        /* offset (from SMB hdr start) to next cmd (@smb_wct) */
  4068.   WORD   smb_fid;         /* file handle */
  4069. + WORD   smb_attribute;   /* attributes of file or device */
  4070. +DWORD   smb_time;        /* last modification time */
  4071. +DWORD   smb_size;        /* current file size */
  4072. + WORD   smb_access;      /* access permissions actually allowed */
  4073. + WORD   smb_type;        /* file type */
  4074. + WORD   smb_state;       /* state of IPC device (e.g. pipe) */
  4075.   WORD   smb_action;      /* action taken */
  4076.  DWORD   smb_fileid;      /* server unique file id */
  4077.   WORD   smb_rsvd;        /* reserved */
  4078.   WORD   smb_bcc;         /* value = 0 */
  4079.  
  4080. + returned only if bit 0 of smb_flags is set in request
  4081.  
  4082. Service Enhancement:
  4083.  
  4084. The open protocol request is enhanced in order  to  accommo-
  4085. date the new open system call used in OS/2 and provide addi-
  4086. tional functionality.
  4087.  
  4088.  
  4089.  
  4090. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096. SMB Protocol Extensions    - 63 -           November 7, 1988
  4097.  
  4098.  
  4099. The entire message sent and received including the  optional
  4100. second  protocol  must  fit  in  the negotiated max transfer
  4101. size.
  4102.  
  4103. The following are the only valid protocol requests  commands
  4104. for smb_com2 (X) for OPEN and X:
  4105.  
  4106.         READ
  4107.         READ and X
  4108.         IOCTL
  4109.  
  4110.  
  4111. The "mode" field for open, referenced as  r/w/share  in  the
  4112. core  protocol  document, is enhanced to allow direct access
  4113. mode for the file, and to allow an open for  execute.   Sys-
  4114. tems  that do not support execute mode should treat the exe-
  4115. cute mode as equivalent to read mode. This word has the fol-
  4116. lowing format:
  4117.  
  4118. smb_mode bit field mapping:
  4119.   bits:
  4120.        1111 11
  4121.        5432 1098 7654 3210
  4122.        rWrr rrrr rSSS rAAA
  4123.   where:
  4124.        W - Write through mode. No read ahead or write behind
  4125. allowed on this
  4126.            file (or device).   When  protocol  is  returned,
  4127. data is expected
  4128.            to be on the disk (or device).
  4129.  
  4130.        r - reserved (must be zero).
  4131.  
  4132.        SSS - Sharing mode
  4133.          0 -- Compatibility mode (as in core open protocol)
  4134.          1 -- Deny read/write/execute (exclusive).
  4135.          2 -- Deny write.
  4136.          3 -- Deny read/execute.
  4137.          4 -- Deny none.
  4138.  
  4139.        AAA - Access mode
  4140.          0 -- Open for reading.
  4141.          1 -- Open for writing.
  4142.          2 -- Open for reading and writing.
  4143.          3 -- Open for execute
  4144.  
  4145.  
  4146.        rSSSrAAA = 11111111 (hex FF)
  4147.  
  4148.          indicates FCB open (as in core open protocol)
  4149.  
  4150.  
  4151. The "open function" field specifies the action to  be  taken
  4152. depending  on whether or not the file exists.  This word has
  4153.  
  4154.  
  4155.  
  4156. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  4157.  
  4158.  
  4159.  
  4160.  
  4161.  
  4162. SMB Protocol Extensions    - 64 -           November 7, 1988
  4163.  
  4164.  
  4165. the following format:
  4166.  
  4167.  
  4168. smb_ofun bit field mapping:
  4169.   bits:
  4170.        1111 11
  4171.        5432 1098 7654 3210
  4172.        rrrr rrrr rrrC rrOO
  4173.  
  4174.   where:
  4175.        C - Create (action to  be  taken  if  file  does  not
  4176. exist).
  4177.          0 -- Fail.
  4178.          1 -- Create file.
  4179.  
  4180.        r - reserved (must be zero).
  4181.  
  4182.        O - Open (action to be taken if file exists).
  4183.          0 - Fail.
  4184.          1 - Open file.
  4185.          2 - Truncate file.
  4186.  
  4187.  
  4188.  
  4189.  
  4190. I/O devices can be opened in a queuing mode, in that if  the
  4191. device  (or  all  devices of type requested) is currently in
  4192. use the user may optionally queue waiting for the device  to
  4193. become  free.   Thus a non zero smb_timeout field is used to
  4194. indicate that queuing is desired.
  4195.  
  4196. If queuing is requested, the value in the smb_timeout  field
  4197. is  used  as  the maximum number of milliseconds to wait for
  4198. the device to become free.  A value of zero means  no  delay
  4199. (do  not queue), a value of (long) -1 indicates to wait for-
  4200. ever (no timeout).  The server will not  send  the  response
  4201. back  to the consumer until the resource being queued for is
  4202. actually opened (or the specified timeout time has  passed).
  4203. Note  that although the timeout is specified in milliseconds
  4204. (in order to match the OS/2 system calls), by the time  that
  4205. the  timeout  occurs  and  the consumer receives the timeout
  4206. protocol much more time than specified may have occurred.
  4207.  
  4208.  
  4209. The "Action Taken" field specifies the action as a result of
  4210. the Open request.  This word has the following format:
  4211.  
  4212.  
  4213. smb_action bit field mapping:
  4214.   bits:
  4215.        1111 11
  4216.        5432 1098 7654 3210
  4217.        Lrrr rrrr rrrr rrOO
  4218.  
  4219.  
  4220.  
  4221.  
  4222. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  4223.  
  4224.  
  4225.  
  4226.  
  4227.  
  4228. SMB Protocol Extensions    - 65 -           November 7, 1988
  4229.  
  4230.  
  4231.   where:
  4232.        L - Lock (single user total file lock status).
  4233.          0 -- file opened by another user (or mode not  sup-
  4234. ported by server).
  4235.          1 -- file is  opened  only  by  this  user  at  the
  4236. present time.
  4237.  
  4238.        r - reserved (must be zero).
  4239.  
  4240.        O - Open (action taken on Open).
  4241.          1 - The file existed and was opened.
  4242.          2 - The file did not exist but was created.
  4243.          3 - The file existed and was truncated.
  4244.  
  4245.  
  4246.  
  4247.  
  4248. The attribute fields (smb_attr, smb_sattr and smb_attribute)
  4249. have  the  following  format  (bit0 is the least significant
  4250. bit).  This field matches that used by OS/2.
  4251.  
  4252.         bit0 - read only file
  4253.         bit1 - "hidden" file
  4254.         bit2 - system file
  4255.         bit3 - reserved
  4256.         bit4 - directory
  4257.         bit5  - archive file
  4258.         bits6-15 - reserved (must be zero)
  4259.  
  4260.  
  4261. The search attribute field (smb_sattr) indicates the  attri-
  4262. butes that the file must have to be found while searching to
  4263. see if it exists.  If the search attribute is zero then only
  4264. normal  files  are  returned.  If the system file, hidden or
  4265. directory  attributes  are  specified  then  the  search  is
  4266. inclusive  -- both the specified type(s) of files and normal
  4267. files are returned.
  4268.  
  4269. The resource type field (smb_type)  defines  the  additional
  4270. resource types:
  4271.  
  4272.  
  4273.                0 - Disk file or directory as defined in the attribute field.
  4274.                1 - FIFO (named pipe)
  4275.                2 - Named pipe (message mode)
  4276.                3 - LPT (printer) Device
  4277.                4 - COM (communication) Device
  4278.  
  4279.  
  4280.  
  4281.  
  4282.  
  4283.  
  4284.  
  4285.  
  4286.  
  4287.  
  4288. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  4289.  
  4290.  
  4291.  
  4292.  
  4293.  
  4294. SMB Protocol Extensions    - 66 -           November 7, 1988
  4295.  
  4296.  
  4297.  
  4298.         IPC State Bits (smb_state)
  4299.               5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  4300.               B E * * T T R R |--- Icount --|
  4301.         where:
  4302.               B - Blocking - 0 => reads/writes block  if  no
  4303.         data available
  4304.                                  1  =>  reads/writes  return
  4305.         immediately if no data
  4306.               E - Endpoint - 0 => consumer end of pipe
  4307.                                  1 => server end of pipe
  4308.               TT - Type of pipe -  00  =>  pipe  is  a  byte
  4309.         stream pipe
  4310.                                       01  =>   pipe   is   a
  4311.         message pipe
  4312.               RR - Read Mode - 00 => Read  pipe  as  a  byte
  4313.         stream
  4314.                                    01 => Read messages  from
  4315.         pipe
  4316.               Icount  -  8-bit   count   to   control   pipe
  4317.         instancing (N/A)
  4318.  
  4319.  
  4320.  
  4321.  
  4322. A "single user total file lock" is also known as an  "oppor-
  4323. tunistic lock".  A consumer requests an "opportunistic lock"
  4324. by setting the appropriate bit in the  OpenX,  Open,  Create
  4325. and MakeNew protocols whenever the file is being opened in a
  4326. mode which is not exclusive.  The server responds by setting
  4327. the  appropriate  bit  in  the  response protocol indicating
  4328. whether or not the "opportunistic  lock"  was  granted.   By
  4329. granting  the  "oplock",  the server tells the consumer that
  4330. the file is currently ONLY being used by this  one  consumer
  4331. process  at  the  current  time.  The consumer can therefore
  4332. safely do read ahead and write behind as well as local cach-
  4333. ing  of  file  locks  knowing  that  the  file  will  not be
  4334. accessed/changed in any way by  another  process  while  the
  4335. "oplock" is in effect.
  4336.  
  4337. The  consumer  will  be  notified  when  any  other  process
  4338. attempts to open the "oplocked" file and if "opbatch" (bit 2
  4339. of smb_flags) was set on the  OpenX  request,  the  consumer
  4340. will  also be notified on any operation which may change the
  4341. file.
  4342.  
  4343. When another user attempts to Open (or otherwise  modify  if
  4344. "opbatch"  was  requested)  the  file  which  a consumer has
  4345. oplocked, the server will "hold off"  the  2nd  attempt  and
  4346. notify the consumer via a LockingX protocol (with bit one of
  4347. smb_locktype set) that the "oplock" is  being  broken.   The
  4348. consumer is expected to then flush any dirty buffers, submit
  4349. any file locks (LockingX protocol can be used for this)  and
  4350. respond  to the server with either a LockingX protocol (with
  4351.  
  4352.  
  4353.  
  4354. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  4355.  
  4356.  
  4357.  
  4358.  
  4359.  
  4360. SMB Protocol Extensions    - 67 -           November 7, 1988
  4361.  
  4362.  
  4363. bit one of smb_locktype set) or with a close protocol if the
  4364. file  is  no longer in use.  Note that because a close being
  4365. sent to the server and break oplock  notification  from  the
  4366. server  could  cross  on  the  wire, if the consumer gets an
  4367. oplock notification on a file which it does not  have  open,
  4368. that  notification should be ignored.  Once the "oplock" has
  4369. been broken, the consumer must no longer do any form of data
  4370. or lock caching.  The "oplock" is never reenstated while the
  4371. file is open.  If the file is still open once  the  consumer
  4372. has  been  notified,  the  2nd  opener does not get the file
  4373. "oplocked" along with the open.  If the file  is  closed  by
  4374. the  consumer which had it open, the server is again free to
  4375. grant the new opener the oplock.
  4376.  
  4377. Note that the "oplock" broken notification will only  go  to
  4378. one consumer because after the oplock is broken, any further
  4379. open attempts will just get the oplock request denied.
  4380.  
  4381. Also note that due to timing,  the  consumer  could  get  an
  4382. "oplock"  broken  notification  in a user's data buffer as a
  4383. result of this notification crossing on the wire with a Read
  4384. Raw  request.   The consumer must detect this (use length of
  4385. msg, "FFSMB", MID of -1 and   smb_cmd  of  SMBLockingX)  and
  4386. honor the "oplock" broken notification as usual.  The server
  4387. must also note on receipt of an Read Raw request that  there
  4388. is  an outstanding (unanswered) "oplock" broken notification
  4389. to the consumer and return a zero length  response  denoting
  4390. failure of the read raw request.  The consumer should (after
  4391. responding to the "oplock" broken notification), use a stan-
  4392. dard  read protocol to redo the read request.  This allows a
  4393. file to actually contain data matching  an  "oplock"  broken
  4394. notification and still be read correctly.
  4395.  
  4396. "Oplock" is a  major  performance  win  in  the  real  world
  4397. because  many  files  must be opened in a non exclusive mode
  4398. because the file could be used by  others.   However  often,
  4399. the  files  are not actually in use by multiple users at the
  4400. same instant.
  4401.  
  4402.  
  4403. The following errors may be generated by Open and X.
  4404.  
  4405.         Error Class ERRDOS
  4406.  
  4407.           ERRbadfile
  4408.           ERRnofids
  4409.           ERRnoaccess
  4410.           ERRshare
  4411.           ERRbadaccess
  4412.           <implementation specific>
  4413.  
  4414.  
  4415.  
  4416.  
  4417.  
  4418.  
  4419.  
  4420. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  4421.  
  4422.  
  4423.  
  4424.  
  4425.  
  4426. SMB Protocol Extensions    - 68 -           November 7, 1988
  4427.  
  4428.  
  4429.  
  4430.         Error Class ERRSRV
  4431.  
  4432.           ERRerror
  4433.           ERRaccess
  4434.           ERRinvnid
  4435.           <implementation specific>
  4436.  
  4437.  
  4438.         Error Class ERRHRD
  4439.  
  4440.           <implementation specific>
  4441.  
  4442.  
  4443.  
  4444.  
  4445.  
  4446.  
  4447.  
  4448.  
  4449.  
  4450.  
  4451.  
  4452.  
  4453.  
  4454.  
  4455.  
  4456.  
  4457.  
  4458.  
  4459.  
  4460.  
  4461.  
  4462.  
  4463.  
  4464.  
  4465.  
  4466.  
  4467.  
  4468.  
  4469.  
  4470.  
  4471.  
  4472.  
  4473.  
  4474.  
  4475.  
  4476.  
  4477.  
  4478.  
  4479.  
  4480.  
  4481.  
  4482.  
  4483.  
  4484.  
  4485.  
  4486. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  4487.  
  4488.  
  4489.  
  4490.  
  4491.  
  4492. SMB Protocol Extensions    - 69 -           November 7, 1988
  4493.  
  4494.  
  4495. 9.2.12.  READ and X
  4496.  
  4497. Request Format:
  4498.  
  4499.   BYTE   smb_wct;         /* value = 10 */
  4500.   BYTE   smb_com2;        /* secondary (X) command, 0xFF = none */
  4501.   BYTE   smb_reh2;        /* reserved (must be zero) */
  4502.   WORD   smb_off2;        /* offset (from SMB hdr start) to next cmd (@smb_wct) */
  4503.   WORD   smb_fid;         /* file handle */
  4504.  DWORD   smb_offset;      /* offset in file to begin read */
  4505.   WORD   smb_maxcnt;      /* max number of bytes to return */
  4506.   WORD   smb_mincnt;      /* min number of bytes to return */
  4507.  DWORD   smb_timeout;     /* number of milliseconds to wait for completion */
  4508.   WORD   smb_countleft;   /* bytes remaining to satisfy user's request */
  4509.   WORD   smb_bcc;         /* value = 0 */
  4510.  
  4511.  
  4512.  
  4513. Response Format:
  4514.  
  4515.   BYTE   smb_wct;         /* value = 12 */
  4516.   BYTE   smb_com2;        /* secondary (X) command, 0xFF = none */
  4517.   BYTE   smb_res2;        /* reserved (pad to word) */
  4518.   WORD   smb_off2;        /* offset (from SMB hdr start) to next cmd (@smb_wct) */
  4519.   WORD   smb_remaining;   /* bytes remaining to be read (pipes/devices only) */
  4520.  DWORD   smb_rsvd;        /* reserved */
  4521.   WORD   smb_dsize;       /* number of data bytes (minimum value = 0) */
  4522.   WORD   smb_doff;        /* offset (from start of SMB hdr) to data bytes */
  4523.   WORD   smb_rsvd;        /* reserved (These last 5 words are reserved in */
  4524.  DWORD   smb_rsvd;        /* reserved  order to make the ReadandX response */
  4525.  DWORD   smb_rsvd;        /* reserved  the same size as the WriteandX request) */
  4526.   WORD   smb_bcc;         /* total bytes (including pad bytes) following */
  4527.   BYTE   smb_pad[];       /* (optional) to pad to word or dword boundary */
  4528.   BYTE   smb_data[*];     /* data bytes (* = value of smb_dsize) */
  4529.  
  4530.  
  4531. Service:
  4532.  
  4533. The expanded read and X command allows  reads  to  be  timed
  4534. out,  and  offers a generalized alternative to the core read
  4535. command.
  4536.  
  4537. The entire message sent and received including the  optional
  4538. second  protocol  must  fit  in  the negotiated max transfer
  4539. size.
  4540.  
  4541. The following are the only valid protocol requests  commands
  4542. for smb_com2 (X) for READ and X:
  4543.  
  4544.         CLOSE
  4545.         CLOSE and DISCONNECT
  4546.  
  4547. When the smb_timeout field is  non-zero,  it  specifies  the
  4548. maximum milliseconds the server is to wait for a response to
  4549.  
  4550.  
  4551.  
  4552. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  4553.  
  4554.  
  4555.  
  4556.  
  4557.  
  4558. SMB Protocol Extensions    - 70 -           November 7, 1988
  4559.  
  4560.  
  4561. its read command.  This feature  is  useful  when  accessing
  4562. remote  devices,  such  as  terminals,  where  indeterminate
  4563. delays are possible.
  4564.  
  4565. The Read command's scope is extended to Named Pipes and  I/O
  4566. Devices.  Timeout and mincnt values are normally expected to
  4567. be used only with these devices.  In the  case  of  a  named
  4568. pipe  or  I/O  device,  timeout is defined to be the time to
  4569. delay for at least smb_mincnt bytes.
  4570.  
  4571. If smb_timeout is zero  (or  the  server  does  not  support
  4572. timeout) and no data is currently available, the server will
  4573. send a response with the smb_dsize field set to zero.
  4574.  
  4575. If smb_timeout is non zero and the server supports  timeout,
  4576. the  server  will  wait  to send the response until the data
  4577. becomes available or a timeout occurs.   If  smb_timeout  is
  4578. greater  than  zero  (but  less  than  forever  (-1) ) and a
  4579. timeout occurs, the server will send  a  response  with  the
  4580. smb_err  field  set  to  indicate  that the timeout occurred
  4581. along with any bytes already read.
  4582.  
  4583. The return field smb_remaining is to be returned  for  pipes
  4584. or  devices  only.  It is used to return the number of bytes
  4585. currently available in the pipe or device (NOT including the
  4586. bytes returned in this buffer). This information can then be
  4587. used by the consumer to know when a subsequent  (non  block-
  4588. ing)  read of the pipe or device may return some data.  Note
  4589. - that when the read request is  actually  received  by  the
  4590. server  there may be more or less actual data in the pipe or
  4591. device (more data has been written to the pipe /  device  or
  4592. another reader drained it).  If the information is currently
  4593. not available or the request is NOT for a pipe or device (or
  4594. the server does not support this feature), a -1 value should
  4595. be returned.
  4596.  
  4597. A negative 2 smb_timeout value  indicates  that  the  server
  4598. should  use  the  default  timeout value associated with the
  4599. pipe or device being read.  Thus no  timeout  is  explicitly
  4600. set  to  the resource, rather the current timeout set either
  4601. as a default or as a result of an IOCTL remains in effect.
  4602.  
  4603. Read and X may generate the following errors:
  4604.  
  4605.         Error Class ERRDOS:
  4606.  
  4607.           ERRnoaccess
  4608.           ERRbadfid
  4609.           ERRlock
  4610.           ERRbadaccess
  4611.  
  4612.  
  4613.  
  4614.  
  4615.  
  4616.  
  4617.  
  4618. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  4619.  
  4620.  
  4621.  
  4622.  
  4623.  
  4624. SMB Protocol Extensions    - 71 -           November 7, 1988
  4625.  
  4626.  
  4627.  
  4628.         Error Class ERRSRV:
  4629.  
  4630.           ERRerror
  4631.           ERRinvnid
  4632.           ERRtimeout
  4633.           <implementation specific>
  4634.  
  4635.  
  4636.         Error Class ERRHRD:
  4637.  
  4638.           <implementation specific>
  4639.  
  4640.  
  4641.  
  4642.  
  4643.  
  4644.  
  4645.  
  4646.  
  4647.  
  4648.  
  4649.  
  4650.  
  4651.  
  4652.  
  4653.  
  4654.  
  4655.  
  4656.  
  4657.  
  4658.  
  4659.  
  4660.  
  4661.  
  4662.  
  4663.  
  4664.  
  4665.  
  4666.  
  4667.  
  4668.  
  4669.  
  4670.  
  4671.  
  4672.  
  4673.  
  4674.  
  4675.  
  4676.  
  4677.  
  4678.  
  4679.  
  4680.  
  4681.  
  4682.  
  4683.  
  4684. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  4685.  
  4686.  
  4687.  
  4688.  
  4689.  
  4690. SMB Protocol Extensions    - 72 -           November 7, 1988
  4691.  
  4692.  
  4693. 9.2.13.  READ BLOCK MULTIPLEXED
  4694.  
  4695. Request Format:
  4696.  
  4697.   BYTE   smb_wct;       /* value = 08 */
  4698.   WORD   smb_fid;       /* file handle */
  4699.  DWORD   smb_offset;    /* offset in file to begin read */
  4700.   WORD   smb_maxcnt;    /* max number of bytes to return (max 65,535) */
  4701.   WORD   smb_mincnt;    /* min number of bytes to return (normally 0) */
  4702.  DWORD   smb_timeout;   /* number of milliseconds to wait for completion */
  4703.   WORD   smb_rsvd;      /* reserved */
  4704.   WORD   smb_bcc;       /* value = 0 */
  4705.  
  4706.  
  4707.  
  4708. Response Format (one or more of these are returned):
  4709.  
  4710.   BYTE   smb_wct;         /* value = 8 */
  4711.  DWORD   smb_offset;      /* offset in file where data read  */
  4712.   WORD   smb_tcount;      /* total bytes being returned this protocol */
  4713.   WORD   smb_remaining;   /* bytes remaining to be read (pipes/devices only) */
  4714.  DWORD   smb_rsvd;        /* reserved */
  4715.   WORD   smb_dsize;       /* number of data bytes this buffer (min value = 0) */
  4716.   WORD   smb_doff;        /* offset (from start of SMB hdr) to data bytes */
  4717.   WORD   smb_bcc;         /* total bytes (including pad bytes) following */
  4718.   BYTE   smb_pad[];       /* (optional) to pad to word or dword boundary */
  4719.   BYTE   smb_data[*];     /* data bytes (* = value of smb_dsize) */
  4720.  
  4721.  
  4722.  
  4723. Service:
  4724.  
  4725. The Read Block Multiplexed protocol is used to maximize  the
  4726. performance of reading a large block of data from the server
  4727. to the consumer on a multiplexed VC.
  4728.  
  4729. The Read Block Multiplexed  command's scope includes (but is
  4730. not  limited  to) files, Named Pipes and  communication dev-
  4731. ices.
  4732.  
  4733. When this protocol is used, other requests may be active  on
  4734. the multiplexed VC.  The server will respond with the one or
  4735. more response protocol message as defined  above  until  the
  4736. requested data amount has been returned.  Each response con-
  4737. tains the smb_pid and smb_mid of the Read Block  Multiplexed
  4738. request, the file offset and data length defined in the Read
  4739. response protocol (including the SMB header).   This  allows
  4740. the  consumer's  message  delivery  (multiplexing) system to
  4741. deliver the response to the appropriate thread.
  4742.  
  4743. The Consumer knows the maximum amount of  data  bytes  which
  4744. the  server  may  return  (from  smb_maxcnt of the request).
  4745. Thus it initializes its  bytes  expected  variable  to  this
  4746. value.   The  Server then informs the consumer of the actual
  4747.  
  4748.  
  4749.  
  4750. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  4751.  
  4752.  
  4753.  
  4754.  
  4755.  
  4756. SMB Protocol Extensions    - 73 -           November 7, 1988
  4757.  
  4758.  
  4759. amount being returned via  each  "packet"  (buffer)  of  the
  4760. response (smb_tcount).
  4761.  
  4762. The server may reduce the expected  bytes  by  lowering  the
  4763. total  number  of  bytes expected (smb_tcount) in each (any)
  4764. response.
  4765.  
  4766. Thus, when the amount of data bytes received (total of  each
  4767. smb_dsize)  equals  the  total amount of data bytes expected
  4768. (smallest  smb_tcount  received),  then  the  consumer   has
  4769. received  all  the  data  bytes. This allows the protocol to
  4770. work even if the "packets" (buffers)  are  received  out  of
  4771. sequence.
  4772.  
  4773. Note that the buffer size being returned  here  can  not  be
  4774. larger  than  the smaller of the  consumer's buffer size (as
  4775. specified in smb_bufsize on the SESSION SETUP and X  request
  4776. protocol)  or  the  server's  buffer  size  (as specified in
  4777. smb_maxxmt of the NEGOTIATE response protocol).
  4778.  
  4779. As is true in the  core  read  protocol,  (while  reading  a
  4780. "standard  blocked  disk  file"),  the total number of bytes
  4781. returned may be be less than the number requested only if  a
  4782. read  specifies bytes beyond the current file size.  In this
  4783. case only the bytes that exist are returned.   A  read  com-
  4784. pletely  beyond  the  end  of  file  will result in a single
  4785. response with a zero value  in  smb_rcount.   If  the  total
  4786. number  of  bytes  returned is less than the number of bytes
  4787. requested, this indicates end of file (if reading other than
  4788. a standard blocked disk file, only ZERO bytes returned indi-
  4789. cates end of file).
  4790.  
  4791.  
  4792. This protocol eliminates nearly half the protocols  involved
  4793. with  reading  a  block  of data since the Read Block Multi-
  4794. plexed request is sent only once as opposed to one for  each
  4795. negotiated buffer size as defined with the Read protocol.
  4796.  
  4797. The transport layer guarantees delivery of all responses  to
  4798. the  consumer.   Thus no "got the data you sent" protocol is
  4799. needed.  If an error should occur at the consumer  end,  all
  4800. bytes must be received and thrown away.  There is no need to
  4801. inform the server of the error.
  4802.  
  4803. Once  started,  the  Read  Block  Multiplexed  operation  is
  4804. expected  to  go to completion.  The consumer is expected to
  4805. receive all the responses generated  by  the  server.   Con-
  4806. flicting  commands  (such as file close) must not be sent to
  4807. the server while a multiplexed operation is in progress.
  4808.  
  4809. The flow for the Read Block  Multiplexed  (R.B.M.)  protocol
  4810. is:
  4811.  
  4812.      consumer ------> R. B. M. request >-------> server
  4813.  
  4814.  
  4815.  
  4816. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  4817.  
  4818.  
  4819.  
  4820.  
  4821.  
  4822. SMB Protocol Extensions    - 74 -           November 7, 1988
  4823.  
  4824.  
  4825.      consumer < R. B. M. response 1 with data <  server
  4826.      consumer < R. B. M. response 2 with data <  server
  4827.      .                       .                        .
  4828.      consumer < R. B. M. response n with data <  server
  4829.  
  4830.  
  4831. Note that the request through the final response make up the
  4832. complete  protocol,  thus  the  TID,  PID,  UID  and MID are
  4833. expected to remain constant and can be used by the  consumer
  4834. to  route  the  individual  messages  of the protocol to the
  4835. correct process.
  4836.  
  4837.  
  4838. The return field smb_remaining is to be returned  for  pipes
  4839. or  devices  only.  It is used to return the number of bytes
  4840. currently available in the pipe or device (NOT including the
  4841. bytes  returned  with  this  protocol). This information can
  4842. then be used by the consumer to know when a subsequent  (non
  4843. blocking)  read  of the pipe or device may return some data.
  4844. Note - that when the read request is  actually  received  by
  4845. the server there may be more or less actual data in the pipe
  4846. or device (more data has been written to the pipe  /  device
  4847. or  another  reader  drained  it).   If  the  information is
  4848. currently not available or the request is NOT for a pipe  or
  4849. device  (or  the server does not support this feature), a -1
  4850. value should be returned.
  4851.  
  4852.  
  4853. Read Block Multiplexed may generate  the  following  errors.
  4854. Note  that  the  error  ERRnoresource  (or ERRusestd) may be
  4855. returned by the server if it is  temporarily  out  of  large
  4856. buffers.   The  consumer could then retry using the standard
  4857. "core" read request, or delay and retry the read block  mul-
  4858. tiplexed request.
  4859.  
  4860.         Error Class ERRDOS
  4861.  
  4862.           ERRnoaccess
  4863.           ERRbadfid
  4864.           ERRlock
  4865.           ERRbadaccess
  4866.           <implementation specific>
  4867.  
  4868.  
  4869.         Error Class ERRSRV
  4870.  
  4871.           ERRerror
  4872.           ERRinvnid
  4873.           ERRnoresource
  4874.           ERRusestd
  4875.           ERRtimeout
  4876.           <implementation specific>
  4877.  
  4878.  
  4879.  
  4880.  
  4881.  
  4882. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  4883.  
  4884.  
  4885.  
  4886.  
  4887.  
  4888. SMB Protocol Extensions    - 75 -           November 7, 1988
  4889.  
  4890.  
  4891.  
  4892.         Error Class ERRHRD
  4893.  
  4894.           <implementation specific>
  4895.  
  4896.  
  4897.  
  4898.  
  4899.  
  4900.  
  4901.  
  4902.  
  4903.  
  4904.  
  4905.  
  4906.  
  4907.  
  4908.  
  4909.  
  4910.  
  4911.  
  4912.  
  4913.  
  4914.  
  4915.  
  4916.  
  4917.  
  4918.  
  4919.  
  4920.  
  4921.  
  4922.  
  4923.  
  4924.  
  4925.  
  4926.  
  4927.  
  4928.  
  4929.  
  4930.  
  4931.  
  4932.  
  4933.  
  4934.  
  4935.  
  4936.  
  4937.  
  4938.  
  4939.  
  4940.  
  4941.  
  4942.  
  4943.  
  4944.  
  4945.  
  4946.  
  4947.  
  4948. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  4949.  
  4950.  
  4951.  
  4952.  
  4953.  
  4954. SMB Protocol Extensions    - 76 -           November 7, 1988
  4955.  
  4956.  
  4957. 9.2.14.  READ BLOCK RAW
  4958.  
  4959. Request Format:
  4960.  
  4961.   BYTE   smb_wct;       /* value = 08 */
  4962.   WORD   smb_fid;       /* file handle */
  4963.  DWORD   smb_offset;    /* offset in file to begin read */
  4964.   WORD   smb_maxcnt;    /* max number of bytes to return (max 65,535) */
  4965.   WORD   smb_mincnt;    /* min number of bytes to return (normally 0) */
  4966.  DWORD   smb_timeout;   /* number of milliseconds to wait for completion */
  4967.   WORD   smb_rsvd;      /* reserved */
  4968.   WORD   smb_bcc;       /* value = 0 */
  4969.  
  4970.  
  4971.  
  4972. Response is the raw data (one send).
  4973.  
  4974.  
  4975. Service:
  4976.  
  4977. The Read Block Raw protocol is used to maximize the  perfor-
  4978. mance  of  reading  a large block of data from the server to
  4979. the consumer.
  4980.  
  4981. The Read Block Raw command's scope includes (but is not lim-
  4982. ited to) files, Named Pipes and  communication devices.
  4983.  
  4984. When this protocol is used, the consumer has guaranteed that
  4985. there  is  (and  will be) no other request on the VC for the
  4986. duration of the Read Block Raw  request.   The  server  will
  4987. respond  with  the raw data being read (one send).  Thus the
  4988. consumer is able to request up to 65,535 bytes of  data  and
  4989. receive  it  directly  into  the user buffer.  Note that the
  4990. amount of data requested is expected to be larger  than  the
  4991. negotiated buffer size for this protocol.
  4992.  
  4993. The reason that no other requests can be active  on  the  VC
  4994. for  the  duration  of the request is that if other receives
  4995. are present on the VC, there is normally no way to guarantee
  4996. that  the  data will be received into the user space, rather
  4997. the data may fill one (or more) of the other buffers.
  4998.  
  4999. The number of bytes actually returned is determined  by  the
  5000. length  of  the message the consumer receives as reported by
  5001. the transport layer (there are no overhead "header bytes").
  5002.  
  5003. If the request is to read more bytes than are present in the
  5004. file,  the read response will be of the length actually read
  5005. from the file.
  5006.  
  5007. If none of the requested  bytes  exist  (EOF)  or  an  error
  5008. occurs on the read, the server will respond with a zero byte
  5009. send.  Upon receipt of a zero length response, the  consumer
  5010. will  send  a  "standard  read"  request to the server.  The
  5011.  
  5012.  
  5013.  
  5014. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  5015.  
  5016.  
  5017.  
  5018.  
  5019.  
  5020. SMB Protocol Extensions    - 77 -           November 7, 1988
  5021.  
  5022.  
  5023. response to that read will then tell the consumer  that  EOF
  5024. was hit or identify the error condition.
  5025.  
  5026. As is true in the  core  read  protocol,  (while  reading  a
  5027. "standard  blocked disk file"), the number of bytes returned
  5028. may be less than the number requested only if a read  speci-
  5029. fies  bytes beyond the current file size.  In this case only
  5030. the bytes that exist are returned.  A read completely beyond
  5031. the  end  of  file will result in a response of zero length.
  5032. If the number of bytes returned is less than the  number  of
  5033. bytes  requested,  this  indicates  end  of file (if reading
  5034. other than a standard blocked disk  file,  only  ZERO  bytes
  5035. returned indicates end of file).
  5036.  
  5037. The transport layer  guarantees  delivery  of  all  response
  5038. bytes to the consumer.  Thus no "got the data you sent" pro-
  5039. tocol is needed.
  5040.  
  5041. If an error should occur at the consumer end, all bytes must
  5042. be received and thrown away.  There is no need to inform the
  5043. server of the error.
  5044.  
  5045. Support of this protocol is optional.
  5046.  
  5047. Whether or not Read Block Raw is supported  is  returned  in
  5048. the  response  to  negotiate  and in the LANMAN 1.0 extended
  5049. "Query Server Information" protocol.
  5050.  
  5051. The flow for reading a sequential file  (or  down-loading  a
  5052. program) using the Block Read Raw protocol is:
  5053.  
  5054.      consumer ---> OPEN for read request >-----> server
  5055.      consumer <-< OPEN succeeded response <----  server
  5056.  
  5057.      consumer --> BLOCK READ RAW request 1 >---> server
  5058.      consumer <----< raw data returned <-------- server
  5059.      consumer --> BLOCK READ RAW request 2 >---> server
  5060.      consumer <----< raw data returned <-------  server
  5061.      .                       .                        .
  5062.      consumer --> BLOCK READ RAW request n >---> server
  5063.      consumer < ZERO LEN SEND (EOF or ERROR) <-  server
  5064.      consumer --> "standard" READ request >----> server
  5065.      consumer <-< READ response EOF/ERROR <----  server
  5066.  
  5067.      consumer -------> CLOSE request >---------> server
  5068.      consumer <-< CLOSE succeeded response <---- server
  5069.  
  5070. This approach minimizes the  number  of  overhead  protocols
  5071. (and bytes) required.
  5072.  
  5073.  
  5074. Read Block Raw may generate NO errors.  Because the response
  5075. to  this  protocol  is raw data only, a zero length response
  5076. indicates  EOF,  a  read  error  or  that  the   server   is
  5077.  
  5078.  
  5079.  
  5080. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  5081.  
  5082.  
  5083.  
  5084.  
  5085.  
  5086. SMB Protocol Extensions    - 78 -           November 7, 1988
  5087.  
  5088.  
  5089. temporarily  out  of large buffers. The consumer should then
  5090. retry using a Multiplexed Read Request or a standard  "core"
  5091. read  request.  This request will then either return the EOF
  5092. condition, an error if the read is still  failing,  or  will
  5093. work  if  the  problem  was  due to being temporarily out of
  5094. large buffers.
  5095.  
  5096.  
  5097.  
  5098.  
  5099.  
  5100.  
  5101.  
  5102.  
  5103.  
  5104.  
  5105.  
  5106.  
  5107.  
  5108.  
  5109.  
  5110.  
  5111.  
  5112.  
  5113.  
  5114.  
  5115.  
  5116.  
  5117.  
  5118.  
  5119.  
  5120.  
  5121.  
  5122.  
  5123.  
  5124.  
  5125.  
  5126.  
  5127.  
  5128.  
  5129.  
  5130.  
  5131.  
  5132.  
  5133.  
  5134.  
  5135.  
  5136.  
  5137.  
  5138.  
  5139.  
  5140.  
  5141.  
  5142.  
  5143.  
  5144.  
  5145.  
  5146. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  5147.  
  5148.  
  5149.  
  5150.  
  5151.  
  5152. SMB Protocol Extensions    - 79 -           November 7, 1988
  5153.  
  5154.  
  5155. 9.2.15.  SESSION SETUP and X
  5156.  
  5157. Request Format:
  5158.  
  5159.   BYTE   smb_wct;          /* value = 10 */
  5160.   BYTE   smb_com2;         /* secondary (X) command, 0xFF = none */
  5161.   BYTE   smb_reh2;         /* reserved (must be zero) */
  5162.   WORD   smb_off2;         /* offset (from SMB hdr start) to next cmd (@smb_wct) */
  5163.   WORD   smb_bufsize;      /* the consumers max buffer size */
  5164.   WORD   smb_mpxmax;       /* actual maximum multiplexed pending requests */
  5165.   WORD   smb_vc_num;       /* 0 = first (only), non zero - additional VC number */
  5166.  DWORD   smb_sesskey;      /* Session Key (valid only if smb_vc_num != 0) */
  5167.   WORD   smb_apasslen;     /* size of account password (smb_apasswd) */
  5168.  DWORD   smb_rsvd;         /* reserved */
  5169.   WORD   smb_bcc;          /* minimum value = 0 */
  5170.   BYTE   smb_apasswd[*];   /* account password (* = smb_apasslen value) */
  5171.   BYTE   smb_aname[];      /* account name string */
  5172.  
  5173.  
  5174. Response Format:
  5175.  
  5176.   BYTE   smb_wct;      /* value = 3 */
  5177.   BYTE   smb_com2;     /* secondary (X) command, 0xFF = none */
  5178.   BYTE   smb_res2;     /* reserved (pad to word) */
  5179.   WORD   smb_off2;     /* offset (from SMB hdr start) to next cmd (@smb_wct) */
  5180.   WORD   smb_action;   /* request mode:
  5181.                        bit0 = Logged in successfully - BUT as GUEST */
  5182.   WORD   smb_bcc;      /* value = 0 */
  5183.  
  5184.  
  5185. Service definition:
  5186.  
  5187. This protocol is used to further "Set up" the  session  nor-
  5188. mally just established via the negotiate protocol.
  5189.  
  5190. One primary function is to perform a  "user  logon"  in  the
  5191. case  where  the  server  is  in "user level security mode".
  5192. Here, the userid value (smb_uid of the SMB header) is set by
  5193. the consumer to be the userid desired for the account (user)
  5194. name supplied in smb_aname  and  validated  by  the  account
  5195. (user)  password  supplied  in  smb_apasswd  (if a passwd is
  5196. required).
  5197.  
  5198. Because the account password may be encrypted, it is a vari-
  5199. able  length field with the length specified by smb_apasslen
  5200. (if password  encryption  is  not  being  used,  smb_apasswd
  5201. should  be  a null terminated ASCII string with smb_apasslen
  5202. set to the string size including the null).
  5203.  
  5204. The server validates the name and password supplied  and  if
  5205. valid,  it registers the UID (in smb_uid) on this session as
  5206. representing the specified account (user) name.  The smb_uid
  5207. field  will  then  be  used to validate access on subsequent
  5208. protocol requests.  The protocol requests  where  permission
  5209.  
  5210.  
  5211.  
  5212. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  5213.  
  5214.  
  5215.  
  5216.  
  5217.  
  5218. SMB Protocol Extensions    - 80 -           November 7, 1988
  5219.  
  5220.  
  5221. checks  are required are those which refer to a symbolically
  5222. named resource such as OPEN, RENAME, DELETE, TRANSACT, etc..
  5223.  
  5224. In networks with untrusted consumers, the value of  the  UID
  5225. (smb_uid) is relative to a session so it is possible to have
  5226. the same UID value represent two different users on two dif-
  5227. ferent sessions at the server.  The server must map the ses-
  5228. sion id and the value in smb_uid) to a unique account.
  5229.  
  5230. In networks with trusted consumers, it is  allowed  to  pass
  5231. only  the UID (no account name/password).  On these systems,
  5232. UIDs are unique and validated user IDs.
  5233.  
  5234. Multiple session setup commands  may  be  sent  to  register
  5235. additional users on this session.  If the server receives an
  5236. additional  Session  Setup  protocol,  only   the   smb_uid,
  5237. smb_aname  and  smb_apasswd fields need contain valid values
  5238. (the server  will  ignore  the  other  fields).   The  error
  5239. "ERRtoomanyuids" will be returned if the server can not sup-
  5240. port the additional UID requested.
  5241.  
  5242. If the server is in "share level security mode", the account
  5243. name and passwd should be ignored by the server.
  5244.  
  5245. Another function of the Session Set Up protocol is to inform
  5246. the  server  of the maximum values which will be utilized by
  5247. this consumer.
  5248.  
  5249. Here smb_bufsize is the maximum message size which the  con-
  5250. sumer can receive.  Thus although the server may support 16k
  5251. buffers (as returned in the negotiate response), if the con-
  5252. sumer  only  has  4k  buffers, the value of smb_bufsize here
  5253. would be 4096.
  5254.  
  5255. The minimum SMB buffer size (smb_maxxmt) is 1024 bytes (1k).
  5256. This  provides  sufficient room for most protocols including
  5257. the simple "request-response" mode of the IOCTL protocol.
  5258.  
  5259. Note that smb_maxxmt returned in the NEGOTIATE  response  is
  5260. the  server buffer size supported.  Thus this is the max SMB
  5261. message size which the consumer  can  send  to  the  server.
  5262. This  size  may  be  larger than smb_bufsize returned to the
  5263. server from the consumer via the  SESSION SETUP and X proto-
  5264. col  which  is the maximum SMB message size which the server
  5265. may send to the consumer.
  5266.  
  5267. Thus if the server's buffer size (as indicated in smb_maxxmt
  5268. on  NEGOTIATE)  were  4k and the consumer's buffer size were
  5269. only 2k (as indicated in smb_bufsize on  SESSION  SETUP  and
  5270. X),   The  consumer  could  send  up  to 4k (standard) write
  5271. requests but must only request up to 2k for (standard)  read
  5272. requests.   The  max  transaction  response  from the server
  5273. would also be 2k.
  5274.  
  5275.  
  5276.  
  5277.  
  5278. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  5279.  
  5280.  
  5281.  
  5282.  
  5283.  
  5284. SMB Protocol Extensions    - 81 -           November 7, 1988
  5285.  
  5286.  
  5287. The field, smb_mpxmax informs  the  server  of  the  maximum
  5288. number  of requests which the consumer will have outstanding
  5289. on a given VC simultaneously.
  5290.  
  5291. The values for smb_bufsize, smb_mpxmax, and smb_vc_num  must
  5292. be less than or equal to the maximum values supported by the
  5293. server as returned in the negotiate response.
  5294.  
  5295. The smb_vc_num field specifies whether  the  consumer  wants
  5296. this to be the first VC or an additional VC.
  5297.  
  5298. If the server gets a Session Set UP request  with  vc_number
  5299. of  0  and other VCs are still connected (to that consumer),
  5300. they will be aborted thus freeing any resources held.   This
  5301. condition  could  occur  if  the  consumer  was rebooted and
  5302. reconnected to the server before  the  transport  level  had
  5303. informed the server of the previous VC termination.
  5304.  
  5305. Because most transports do not make it easy to use differing
  5306. size  buffers  on the same VC, the buffer size is negotiated
  5307. at negotiate time rather than at Tree Connect time.  The new
  5308. expanded  Tree Connect protocol (TREE_CONNECTandX) no longer
  5309. negotiates buffer sizes.  If buffer sizes are needed at Tree
  5310. Connect  time, the core version of TREE CONNECT may still be
  5311. used.
  5312.  
  5313. The entire message sent and received including the  optional
  5314. second  protocol  must  fit  in  the negotiated max transfer
  5315. size.
  5316.  
  5317. The following are the only valid protocol requests  commands
  5318. for smb_com2 (X) for Session SETUP and X:
  5319.  
  5320.  
  5321.  
  5322.  
  5323.  
  5324.  
  5325.  
  5326.  
  5327.  
  5328.  
  5329.  
  5330.  
  5331.  
  5332.  
  5333.  
  5334.  
  5335.  
  5336.  
  5337.  
  5338.  
  5339.  
  5340.  
  5341.  
  5342.  
  5343.  
  5344. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  5345.  
  5346.  
  5347.  
  5348.  
  5349.  
  5350. SMB Protocol Extensions    - 82 -           November 7, 1988
  5351.  
  5352.  
  5353.  
  5354.         TREE CONNECT and X
  5355.         OPEN FILE
  5356.         OPEN and X
  5357.         CREATE FILE
  5358.         MAKE NEW FILE
  5359.         CREATE DIRECTORY
  5360.         DELETE FILE
  5361.         DELETE DIRECTORY
  5362.         FILE SEARCH
  5363.         FIND
  5364.         FIND UNIQUE
  5365.         COPY FILE
  5366.         RENAME FILE
  5367.         MOVE FILE
  5368.         CHECK PATH
  5369.         GET FILE ATTRIBUTES
  5370.         SET FILE ATTRIBUTES
  5371.         GET SERVER ATTRIBUTES
  5372.         QUERY SERVER INFO
  5373.         CREATE PRINT FILE
  5374.         GET PRINT QUEUE
  5375.         TRANSACTION
  5376.  
  5377.  
  5378. Session Setup and X may generate the following errors.
  5379.  
  5380.         Error Class ERRDOS
  5381.  
  5382.           <implementation specific>
  5383.  
  5384.  
  5385.         Error Class ERRSRV
  5386.  
  5387.           ERRerror
  5388.           ERRbadpw
  5389.           ERRinvnetname
  5390.           ERRtoomanyuids
  5391.           <implementation specific>
  5392.  
  5393.  
  5394.         Error Class ERRHRD
  5395.  
  5396.           <implementation specific>
  5397.  
  5398.  
  5399.  
  5400.  
  5401.  
  5402.  
  5403.  
  5404.  
  5405.  
  5406.  
  5407.  
  5408.  
  5409.  
  5410. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  5411.  
  5412.  
  5413.  
  5414.  
  5415.  
  5416. SMB Protocol Extensions    - 83 -           November 7, 1988
  5417.  
  5418.  
  5419. 9.2.16.  SET EXPANDED FILE ATTRIBUTES
  5420.  
  5421. Request Format:
  5422.  
  5423.   BYTE   smb_wct;      /* value = 7 */
  5424.   WORD   smb_fid;      /* file handle */
  5425.   WORD   smb_cdate;    /* date of creation */
  5426.   WORD   smb_ctime;    /* time of creation */
  5427.   WORD   smb_adate;    /* date of last access */
  5428.   WORD   smb_atime;    /* time of last access */
  5429.   WORD   smb_mdate;    /* date of last modification */
  5430.   WORD   smb_mtime;    /* time of last modification */
  5431.   WORD   smb_bcc;      /* minimum value = 0 */
  5432.   BYTE   smb_rsvd[];   /* reserved */
  5433.  
  5434.  
  5435.  
  5436. Response Format:
  5437.  
  5438.   BYTE   smb_wct;   /* value = 0 */
  5439.   WORD   smb_bcc;   /* value = 0 */
  5440.  
  5441.  
  5442.  
  5443. Service Enhancement:
  5444.  
  5445. The Expanded Set File Attributes is enhanced to set informa-
  5446. tion  about  the  queried  file.  The target file is updated
  5447. from the  values specified.   A  null  date/time  value  (0)
  5448. indicates to leave that specific date/time unchanged.
  5449.  
  5450. The file is specified by the file handle (FID).
  5451.  
  5452.  
  5453.  
  5454. The dates are in the following format:
  5455.   bits:
  5456.        1111 11
  5457.        5432 1098 7654 3210
  5458.        yyyy yyym mmmd dddd
  5459. where:
  5460.       y - bit of year 0-119 (1980-2099)
  5461.       m - bit of month 1-12
  5462.       d - bit of day 1-31
  5463.  
  5464.  
  5465.  
  5466. The times are in the following format:
  5467.   bits:
  5468.        1111 11
  5469.        5432 1098 7654 3210
  5470.        hhhh hmmm mmmx xxxx
  5471. where:
  5472.       h - bit of hour (0-23)
  5473.  
  5474.  
  5475.  
  5476. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  5477.  
  5478.  
  5479.  
  5480.  
  5481.  
  5482. SMB Protocol Extensions    - 84 -           November 7, 1988
  5483.  
  5484.  
  5485.       m - bit of minute (0-59)
  5486.       x - bit of 2 second increment
  5487.  
  5488.  
  5489.  
  5490. Set Expanded File  Attributes  may  generate  the  following
  5491. errors.
  5492.  
  5493.         Error Class ERRDOS
  5494.  
  5495.           ERRbadfile
  5496.           ERRbadfid
  5497.           ERRnoaccess
  5498.           <implementation specific>
  5499.  
  5500.  
  5501.         Error Class ERRSRV
  5502.  
  5503.           ERRerror
  5504.           ERRinvnid
  5505.           ERRaccess
  5506.           <implementation specific>
  5507.  
  5508.  
  5509.         Error Class ERRHRD
  5510.  
  5511.           <implementation specific>
  5512.  
  5513.  
  5514.  
  5515.  
  5516.  
  5517.  
  5518.  
  5519.  
  5520.  
  5521.  
  5522.  
  5523.  
  5524.  
  5525.  
  5526.  
  5527.  
  5528.  
  5529.  
  5530.  
  5531.  
  5532.  
  5533.  
  5534.  
  5535.  
  5536.  
  5537.  
  5538.  
  5539.  
  5540.  
  5541.  
  5542. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  5543.  
  5544.  
  5545.  
  5546.  
  5547.  
  5548. SMB Protocol Extensions    - 85 -           November 7, 1988
  5549.  
  5550.  
  5551. 9.2.17.  TRANSACTION
  5552.  
  5553. Primary Request Format:
  5554.  
  5555.  
  5556.   BYTE   smb_wct;        /* value = (14 + value of smb_suwcnt) */
  5557.   WORD   smb_tpscnt;     /* total number of parameter bytes being sent */
  5558.   WORD   smb_tdscnt;     /* total number of data bytes being sent */
  5559.   WORD   smb_mprcnt;     /* max number of parameter bytes to return */
  5560.   WORD   smb_mdrcnt;     /* max number of data bytes to return */
  5561.   BYTE   smb_msrcnt;     /* max number of setup words to return */
  5562.   BYTE   smb_rsvd;       /* reserved (pad above to word) */
  5563.   WORD   smb_flags;      /* additional information:
  5564.                          bit 0 - if set, also disconnect TID in smb_tid
  5565.                          bit 1 - if set, transaction is one way (no final response) */
  5566.  DWORD   smb_timeout;    /* number of milliseconds to wait for completion */
  5567.   WORD   smb_rsvd1;      /* reserved */
  5568.   WORD   smb_pscnt;      /* number of parameter bytes being sent this buffer */
  5569.   WORD   smb_psoff;      /* offset (from start of SMB hdr) to parameter bytes */
  5570.   WORD   smb_dscnt;      /* number of data bytes being sent this buffer */
  5571.   WORD   smb_dsoff;      /* offset (from start of SMB hdr) to data bytes */
  5572.   BYTE   smb_suwcnt;     /* set up word count */
  5573.   BYTE   smb_rsvd2;      /* reserved (pad above to word) */
  5574.   WORD   smb_setup[*];   /* variable number of set up words (* = smb_suwcnt) */
  5575.   WORD   smb_bcc;        /* total bytes (including pad bytes) following */
  5576.   BYTE   smb_name[];     /* name of transaction */
  5577.   BYTE   smb_pad[];      /* (optional) to pad to word or dword boundary */
  5578.   BYTE   smb_param[*];   /* param bytes (* = value of smb_pscnt) */
  5579.   BYTE   smb_pad1[];     /* (optional) to pad to word or dword boundary */
  5580.   BYTE   smb_data[*];    /* data bytes (* = value of smb_dscnt) */
  5581.  
  5582.  
  5583.  
  5584. Interim Response Format (if no error  -  ok  send  remaining
  5585. data):
  5586.  
  5587.   BYTE   smb_wct;   /* value = 0 */
  5588.   WORD   smb_bcc;   /* value = 0 */
  5589.  
  5590.  
  5591. Secondary Request Format (more data - may be zero or more of
  5592. these):
  5593.  
  5594.   BYTE   smb_wct;        /* value = 8 */
  5595.   WORD   smb_tpscnt;     /* total number of parameter bytes being sent */
  5596.   WORD   smb_tdscnt;     /* total number of data bytes being sent */
  5597.   WORD   smb_pscnt;      /* number of parameter bytes being sent this buffer */
  5598.   WORD   smb_psoff;      /* offset (from start of SMB hdr) to parameter bytes */
  5599.   WORD   smb_psdisp;     /* byte displacement for these parameter bytes */
  5600.   WORD   smb_dscnt;      /* number of data bytes being sent this buffer */
  5601.   WORD   smb_dsoff;      /* offset (from start of SMB hdr) to data bytes */
  5602.   WORD   smb_dsdisp;     /* byte displacement for these data bytes */
  5603.   WORD   smb_bcc;        /* total bytes (including pad bytes) following */
  5604.   BYTE   smb_pad[];      /* (optional) to pad to word or dword boundary */
  5605.  
  5606.  
  5607.  
  5608. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  5609.  
  5610.  
  5611.  
  5612.  
  5613.  
  5614. SMB Protocol Extensions    - 86 -           November 7, 1988
  5615.  
  5616.  
  5617.   BYTE   smb_param[*];   /* param bytes (* = value of smb_pscnt) */
  5618.   BYTE   smb_pad1[];     /* (optional) to pad to word or dword boundary */
  5619.   BYTE   smb_data[*];    /* data bytes (* = value of smb_dscnt) */
  5620.  
  5621.  
  5622.  
  5623.  
  5624.  
  5625.  
  5626.  
  5627.  
  5628.  
  5629.  
  5630.  
  5631.  
  5632.  
  5633.  
  5634.  
  5635.  
  5636.  
  5637.  
  5638.  
  5639.  
  5640.  
  5641.  
  5642.  
  5643.  
  5644.  
  5645.  
  5646.  
  5647.  
  5648.  
  5649.  
  5650.  
  5651.  
  5652.  
  5653.  
  5654.  
  5655.  
  5656.  
  5657.  
  5658.  
  5659.  
  5660.  
  5661.  
  5662.  
  5663.  
  5664.  
  5665.  
  5666.  
  5667.  
  5668.  
  5669.  
  5670.  
  5671.  
  5672.  
  5673.  
  5674. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  5675.  
  5676.  
  5677.  
  5678.  
  5679.  
  5680. SMB Protocol Extensions    - 87 -           November 7, 1988
  5681.  
  5682.  
  5683. Response Format (may respond with zero or more of these):
  5684.  
  5685.   BYTE   smb_wct;        /* value = (10 + value of smb_suwcnt) */
  5686.   WORD   smb_tprcnt;     /* total number of parameter bytes being returned */
  5687.   WORD   smb_tdrcnt;     /* total number of data bytes being returned */
  5688.   WORD   smb_rsvd;       /* reserved */
  5689.   WORD   smb_prcnt;      /* number of parameter bytes being returned this buf */
  5690.   WORD   smb_proff;      /* offset (from start of SMB hdr) to parameter bytes */
  5691.   WORD   smb_prdisp;     /* byte displacement for these parameter bytes */
  5692.   WORD   smb_drcnt;      /* number of data bytes being returned this buffer */
  5693.   WORD   smb_droff;      /* offset (from start of SMB hdr) to data bytes */
  5694.   WORD   smb_drdisp;     /* byte displacement for these data bytes */
  5695.   BYTE   smb_suwcnt;     /* set up return word count */
  5696.   BYTE   smb_rsvd1;      /* reserved (pad above to word) */
  5697.   WORD   smb_setup[*];   /* variable # of set up return words (* = smb_suwcnt) */
  5698.   WORD   smb_bcc;        /* total bytes (including pad bytes) following */
  5699.   BYTE   smb_pad[];      /* (optional) to pad to word or dword boundary */
  5700.   BYTE   smb_param[*];   /* param bytes (* = value of smb_prcnt) */
  5701.   BYTE   smb_pad1[];     /* (optional) to pad to word or dword boundary */
  5702.   BYTE   smb_data[*];    /* data bytes (* = value of smb_drcnt) */
  5703.  
  5704. Service:
  5705.  
  5706. The Transaction protocol performs a symbolically named tran-
  5707. saction.   This transaction is known only by a name (no file
  5708. handle used).
  5709.  
  5710. The Transaction command's scope includes (but is not limited
  5711. to)  Named Pipes and Mail Slots.  Where the resource is uni-
  5712. directional (such as class 2 writes to Mail Slots), bit 1 of
  5713. smb_flags  on  the  request  can  be  set indicating that no
  5714. response is needed.
  5715.  
  5716. The  Transaction  "set  up  information"  and/or  parameters
  5717. define functions specific to a particular resource on a par-
  5718. ticular server.  Therefore the functions supported  are  not
  5719. defined  by the protocol, but by consumer/server implementa-
  5720. tions.  The protocol simply provides a means  of  delivering
  5721. them and retrieving the results.
  5722.  
  5723. The number of bytes needed in order to perform the  TRANSAC-
  5724. TION request may be more than will fit in a single buffer.
  5725.  
  5726. At the time of the request, the consumer knows the number of
  5727. parameter and data bytes expected to be sent and passes this
  5728. information  to  the  server   via   the   primary   request
  5729. (smb_tpscnt and smb_tdscnt). This may be reduced by lowering
  5730. the  total  number  of  bytes  expected  (smb_tpscnt  and/or
  5731. smbtdscnt) in each (any) secondary request.
  5732.  
  5733. Thus when the amount of parameter bytes received  (total  of
  5734. each  smb_pscnt)  equals the total amount of parameter bytes
  5735. expected (smallest smb_tpscnt) received, then the server has
  5736. received all the parameter bytes.
  5737.  
  5738.  
  5739.  
  5740. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  5741.  
  5742.  
  5743.  
  5744.  
  5745.  
  5746. SMB Protocol Extensions    - 88 -           November 7, 1988
  5747.  
  5748.  
  5749. Likewise, when the amount of data bytes received  (total  of
  5750. each  smb_dscnt)  equals  the  total  amount  of  data bytes
  5751. expected (smallest smb_tdscnt) received, then the server has
  5752. received all the data bytes.
  5753.  
  5754. The parameter bytes should normally be sent  first  followed
  5755. by  the  data  bytes.  However,  the server knows where each
  5756. begins  and  ends  in  each  buffer  by  the  offset  fields
  5757. (smb_psoff  and  smb_dsoff) and the length fields (smb_pscnt
  5758. and smb_dscnt).  The displacement of the bytes (relative  to
  5759. start  of  each)  is also known (smb_psdisp and smb_dsdisp).
  5760. Thus the server is able to reasemble the parameter and  data
  5761. bytes  should  the  "packets"  (buffers)  be received out of
  5762. sequence.
  5763.  
  5764. If all parameter bytes and data  bytes  fit  into  a  single
  5765. buffer,  then no interim response is expected (and no secon-
  5766. dary request is sent).
  5767.  
  5768. The Consumer knows the maximum  amount  of  data  bytes  and
  5769. parameter bytes which the server may return (from smb_mprcnt
  5770. and smb_mdrcnt of the request).   Thus  it  initializes  its
  5771. bytes  expected  variables to these values.  The Server then
  5772. informs the consumer of the actual  amounts  being  returned
  5773. via  each  "packet" (buffer) of the response (smb_tprcnt and
  5774. smb_tdrcnt).
  5775.  
  5776. The server may reduce the expected  bytes  by  lowering  the
  5777. total   number   of   bytes   expected   (smb_tprcnt  and/or
  5778. smb_tdrcnt) in each (any) response.
  5779.  
  5780. Thus when the amount of parameter bytes received  (total  of
  5781. each  smb_prcnt)  equals the total amount of parameter bytes
  5782. expected (smallest smb_tprcnt) received, then  the  consumer
  5783. has received all the parameter bytes.
  5784.  
  5785. Likewise, when the amount of data bytes received  (total  of
  5786. each  smb_drcnt)  equals  the  total  amount  of  data bytes
  5787. expected (smallest smb_tdrcnt) received, then  the  consumer
  5788. has received all the data bytes.
  5789.  
  5790. The parameter bytes should normally be returned  first  fol-
  5791. lowed  by  the data bytes. However, the consumer knows where
  5792. each begins and ends in each buffer  by  the  offset  fields
  5793. (smb_proff  and  smb_droff) and the length fields (smb_prcnt
  5794. and smb_drcnt).  The displacement of the bytes (relative  to
  5795. start  of  each)  is also known (smb_prdisp and smb_drdisp).
  5796. Thus the consumer is able to  reasemble  the  parameter  and
  5797. data bytes should the "packets" (buffers) be received out of
  5798. sequence.
  5799.  
  5800. Thus the flow is:
  5801.  
  5802.  
  5803.  
  5804.  
  5805.  
  5806. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  5807.  
  5808.  
  5809.  
  5810.  
  5811.  
  5812. SMB Protocol Extensions    - 89 -           November 7, 1988
  5813.  
  5814.  
  5815. 1    The consumer sends the first  (primary)  request  which
  5816.      identifies  the  total bytes (both parameters and data)
  5817.      which are expected to be sent and contains the  set  up
  5818.      words and as many of the parameter and data bytes bytes
  5819.      as will fit in a negotiated size buffer.   This request
  5820.      also  identifies  the  maximum  number of bytes (setup,
  5821.      parameters and data) the server is to return  on  TRAN-
  5822.      SACTION  completion. If all the bytes fit in the single
  5823.      buffer, skip to step 4.
  5824.  
  5825.  
  5826. 2    The server responds  with  a  single  interim  response
  5827.      meaning  "ok,  send  the remainder of the bytes" or (if
  5828.      error response) terminate the transaction.
  5829.  
  5830.  
  5831. 3    The consumer then sends another buffer full of bytes to
  5832.      the   server.  On  each  iteration  of  this  secondary
  5833.      request, smb_tpscnt and/or smb_tdscnt could be reduced.
  5834.      This  step  is  repeated  until  all  bytes  have  been
  5835.      delivered to the server (total of all smb_pscnt  equals
  5836.      smallest  smb_tpscnt  and total of all smb_dscnt equals
  5837.      smallest smb_tdscnt).
  5838.  
  5839.  
  5840. 4    The Server sets up and performs  the  TRANSACTION  with
  5841.      the information provided.
  5842.  
  5843.  
  5844. 5    Upon completion of the IOCTL, the server sends back (up
  5845.      to)  the  number  of parameter and data bytes requested
  5846.      (or as many as will fit in the negotiated buffer size).
  5847.      This  step is repeated until all result bytes have been
  5848.      returned.   On  each  iteration   of   this   response,
  5849.      smb_tprcnt  and/or  smb_tdrcnt  could be reduced.  This
  5850.      step is repeated until all bytes have been delivered to
  5851.      the  consumer  (total  of all smb_prcnt equals smallest
  5852.      smb_tprcnt and total of all smb_drcnt  equals  smallest
  5853.      smb_tdrcnt).
  5854.  
  5855.  
  5856.      Thus the flow is:
  5857.  
  5858.  
  5859. 1    The consumer sends the first  (primary)  request  which
  5860.      identifies  the total bytes (parameters and data) which
  5861.      are to be sent, contains the set up words and  as  many
  5862.      of  the parameter and data bytes as will fit in a nego-
  5863.      tiated size buffer.   This request also identifies  the
  5864.      maximum  number  of  bytes (setup, parameters and data)
  5865.      the server is to return on TRANSACTION completion.  The
  5866.      parameter  bytes  are  immediately followed by the data
  5867.      bytes (the length fields identify the break point).  If
  5868.      all the bytes fit in the single buffer, skip to step 4.
  5869.  
  5870.  
  5871.  
  5872. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  5873.  
  5874.  
  5875.  
  5876.  
  5877.  
  5878. SMB Protocol Extensions    - 90 -           November 7, 1988
  5879.  
  5880.  
  5881. 2    The server responds  with  a  single  interim  response
  5882.      meaning  "ok,  send  the remainder of the bytes" or (if
  5883.      error response) terminate the transaction.
  5884.  
  5885.  
  5886. 3    The consumer then sends another buffer full of bytes to
  5887.      the  server. This step is repeated until all bytes have
  5888.      been delivered to the server.
  5889.  
  5890.  
  5891. 4    The Server sets up and performs  the  TRANSACTION  with
  5892.      the information provided.
  5893.  
  5894.  
  5895. 5    Upon completion of the TRANSACTION,  the  server  sends
  5896.      back  up  to the the number of parameter and data bytes
  5897.      requested (or as many as will  fit  in  the  negotiated
  5898.      buffer  size).   This  step is repeated until all bytes
  5899.      requested have been returned.   On  each  iteration  of
  5900.      this response, smb_rprcnt and smb_rdrcnt are reduced by
  5901.      the number of matching bytes returned in  the  previous
  5902.      response.  The parameter count (smb_rprcnt) is expected
  5903.      to go to zero first because  the  parameters  are  sent
  5904.      before  the data.  The data count (smb_rdrcnt) may then
  5905.      continue to be counted down.  Fewer than the  requested
  5906.      number of bytes may be returned.
  5907.  
  5908.  
  5909.  
  5910.  
  5911.  
  5912.  
  5913.  
  5914.  
  5915.  
  5916.  
  5917.  
  5918.  
  5919.  
  5920.  
  5921.  
  5922.  
  5923.  
  5924.  
  5925.  
  5926.  
  5927.  
  5928.  
  5929.  
  5930.  
  5931.  
  5932.  
  5933.  
  5934.  
  5935.  
  5936.  
  5937.  
  5938. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  5939.  
  5940.  
  5941.  
  5942.  
  5943.  
  5944. SMB Protocol Extensions    - 91 -           November 7, 1988
  5945.  
  5946.  
  5947. The flow for  the  TRANSACTION  protocol  when  the  request
  5948. parameters and data does NOT all fit in a single buffer is:
  5949.  
  5950.      consumer -> TRANSACTION request (data) >--> server
  5951.      consumer <--< OK send remaining data <----  server
  5952.      cons> TRANSACTION secondary request 1 (dat> server
  5953.      cons> TRANSACTION secondary request 2 (dat> server
  5954.      .                       .                        .
  5955.      cons> TRANSACTION secondary request n (dat> server
  5956.      .                       .                        .
  5957.      . (server sets up and performs the TRANSACTION)  .
  5958.      .                       .                        .
  5959.      consumer < TRANSACTION response 1 (data) <- server
  5960.      consumer < TRANSACTION response 2 (data) <- server
  5961.      .                       .                        .
  5962.      consumer < TRANSACTION response n (data) <- server
  5963.  
  5964. The flow for  the  Transaction  protocol  when  the  request
  5965. parameters and data does all fit in a single buffer is:
  5966.  
  5967.      consumer -> TRANSACTION request (data) >--> server
  5968.      .                       .                        .
  5969.      . (server sets up and performs the TRANSACTION)  .
  5970.      .                       .                        .
  5971.      consumer < TRANSACTION response 1 (data) <- server
  5972.      .      (only one if all data fit in buffer)      .
  5973.      consumer < TRANSACTION response 2 (data) <- server
  5974.      .                       .                        .
  5975.      consumer < TRANSACTION response n (data) <- server
  5976.  
  5977.  
  5978.  
  5979. Note that the primary request  through  the  final  response
  5980. make  up  the  complete protocol, thus the TID, PID, UID and
  5981. MID are expected to remain constant and can be used by  both
  5982. the  server and consumer to route the individual messages of
  5983. the protocol to the correct process.
  5984.  
  5985.  
  5986. Transaction may generate the following errors:
  5987.  
  5988.         Error Class ERRDOS:
  5989.  
  5990.           ERRnoaccess
  5991.           ERRbadaccess
  5992.  
  5993.  
  5994.         Error Class ERRSRV:
  5995.  
  5996.           ERRerror
  5997.           ERRinvnid
  5998.           ERRaccess
  5999.           ERRmoredata
  6000.           <implementation specific>
  6001.  
  6002.  
  6003.  
  6004. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  6005.  
  6006.  
  6007.  
  6008.  
  6009.  
  6010. SMB Protocol Extensions    - 92 -           November 7, 1988
  6011.  
  6012.  
  6013.  
  6014.         Error Class ERRHRD:
  6015.  
  6016.           <implementation specific>
  6017.  
  6018.  
  6019.  
  6020. 9.2.17.1.  Defined Transaction Protocols
  6021.  
  6022. This section specifies some of the  defined  usages  of  the
  6023. Transaction  protocol.   Each of the usages here utilize the
  6024. basic (and flexible) transaction protocol format.   This  is
  6025. NOT meant to be an exhaustive list.
  6026.  
  6027. Note that the simplest form of a Transaction performs a sin-
  6028. gle  send  of  the Transaction request and (optionally) gets
  6029. back a single response.  Thus if the entire Transaction mes-
  6030. sage  fits within the size limits for a Datagram (defined by
  6031. NetBios to be 512 bytes max) and reliable  delivery  of  the
  6032. information is not required, the Transaction protocol may be
  6033. sent/received as a datagram.
  6034.  
  6035.  
  6036.  
  6037.  
  6038.  
  6039.  
  6040.  
  6041.  
  6042.  
  6043.  
  6044.  
  6045.  
  6046.  
  6047.  
  6048.  
  6049.  
  6050.  
  6051.  
  6052.  
  6053.  
  6054.  
  6055.  
  6056.  
  6057.  
  6058.  
  6059.  
  6060.  
  6061.  
  6062.  
  6063.  
  6064.  
  6065.  
  6066.  
  6067.  
  6068.  
  6069.  
  6070. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  6071.  
  6072.  
  6073.  
  6074.  
  6075.  
  6076. SMB Protocol Extensions    - 93 -           November 7, 1988
  6077.  
  6078.  
  6079. 9.2.17.1.1.  Mail Slot Transaction protocol
  6080.  
  6081.  
  6082. The identifier "\MAILSLOT\<name>" denotes a mail slot  tran-
  6083. saction, where the <name> is the mail slot name to apply the
  6084. transaction against.
  6085.  
  6086. Mail slots using unreliable "class 2" mode may be  transmit-
  6087. ted  via  datagrams.   However,  Mail  slots  using reliable
  6088. "class 1" mode must be  transmitted  on  an  established  VC
  6089. (reliable delivery is needed).
  6090.  
  6091. When "class 1" mail slot transaction are transmitted  via  a
  6092. VC,  a response may still be desired to ensure that the mail
  6093. slot transaction was delivered  to  the  mail  slot  without
  6094. error.   Thus  the  response bit may be zero in smb_flags to
  6095. indicate that the error code associated  with  the  delivery
  6096. should be returned.
  6097.  
  6098.  
  6099. Primary Request Format:
  6100.  
  6101.  
  6102.   BYTE   smb_wct;       /* value = 17 */
  6103.   WORD   smb_tpscnt;    /* value = 0 total number of param bytes being sent */
  6104.   WORD   smb_tdscnt;    /* total size of data to write to mail slot (if any) */
  6105.   WORD   smb_mprcnt;    /* value = 2 one word return code expected */
  6106.   WORD   smb_mdrcnt;    /* value = 0 size of data read from mail slot (N/A) */
  6107.   BYTE   smb_msrcnt;    /* value = 0 max number of setup words to return (N/A)*/
  6108.   BYTE   smb_rsvd;      /* reserved (pad above to word) */
  6109.   WORD   smb_flags;     /* additional information:
  6110.                         bit 0 - if set, also disconnect TID in smb_tid
  6111.                         bit 1 - if set, no response is required */
  6112.  DWORD   smb_timeout;   /* (user defined) number of milliseconds to wait */
  6113.   WORD   smb_rsvd1;     /* reserved */
  6114.   WORD   smb_pscnt;     /* value = 0 no param bytes being sent this buffer */
  6115.   WORD   smb_psoff;     /* value = 0 no parameter bytes */
  6116.   WORD   smb_dscnt;     /* number of data bytes being sent this buffer */
  6117.   WORD   smb_dsoff;     /* offset (from start of SMB hdr) to data bytes */
  6118.   BYTE   smb_suwcnt;    /* value = 3 */
  6119.   BYTE   smb_rsvd2;     /* reserved (pad above to word) */
  6120.   WORD   smb_setup1;    /* (op code) value = 1 - Write Mail slot */
  6121.   WORD   smb_setup2;    /* (priority) priority of transaction */
  6122.   WORD   smb_setup3;    /* (class) 1 = reliable, 2 = unreliable */
  6123.   WORD   smb_bcc;       /* total bytes (including pad bytes) following */
  6124.   BYTE   smb_name[];    /* "\MAILSLOT\<name>0"  */
  6125.   BYTE   smb_pad[];     /* (optional) to pad to word or dword boundary */
  6126.   BYTE   smb_data[*];   /* data to be written to Mail Slot (if any)
  6127.                            (* = value of smb_dscnt) */
  6128.  
  6129.  
  6130.  
  6131.  
  6132.  
  6133.  
  6134.  
  6135.  
  6136. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  6137.  
  6138.  
  6139.  
  6140.  
  6141.  
  6142. SMB Protocol Extensions    - 94 -           November 7, 1988
  6143.  
  6144.  
  6145. Response Format (may respond with zero or more of these):
  6146.  
  6147.   BYTE   smb_wct;       /* value = 10 */
  6148.   WORD   smb_tprcnt;    /* value = 2 one word return code */
  6149.   WORD   smb_tdrcnt;    /* value = 0 no data bytes  */
  6150.   WORD   smb_rsvd;      /* reserved */
  6151.   WORD   smb_prcnt;     /* value = 2 parameter bytes being returned this buf */
  6152.   WORD   smb_proff;     /* offset (from start of SMB hdr) to parameter bytes */
  6153.   WORD   smb_prdisp;    /* value = 0 byte displacement for these param bytes */
  6154.   WORD   smb_drcnt;     /* value = 0 no data bytes */
  6155.   WORD   smb_droff;     /* value = 0 no data bytes */
  6156.   WORD   smb_drdisp;    /* value = 0 no data bytes */
  6157.   BYTE   smb_suwcnt;    /* value = 0 no set up return words */
  6158.   BYTE   smb_rsvd1;     /* reserved (pad above to word) */
  6159.   WORD   smb_bcc;       /* total bytes (including pad bytes) following */
  6160.   BYTE   smb_pad[];     /* (optional) to pad to word or dword boundary */
  6161.   WORD   smb_retcode;   /* mail slot delivery return code (ZERO = OK) */
  6162.  
  6163.  
  6164.  
  6165.  
  6166.  
  6167.  
  6168.  
  6169.  
  6170.  
  6171.  
  6172.  
  6173.  
  6174.  
  6175.  
  6176.  
  6177.  
  6178.  
  6179.  
  6180.  
  6181.  
  6182.  
  6183.  
  6184.  
  6185.  
  6186.  
  6187.  
  6188.  
  6189.  
  6190.  
  6191.  
  6192.  
  6193.  
  6194.  
  6195.  
  6196.  
  6197.  
  6198.  
  6199.  
  6200.  
  6201.  
  6202. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  6203.  
  6204.  
  6205.  
  6206.  
  6207.  
  6208. SMB Protocol Extensions    - 95 -           November 7, 1988
  6209.  
  6210.  
  6211. 9.2.17.1.2.  Announce (and request Announce) Mail Slot Tran-
  6212. saction protocol
  6213.  
  6214.  
  6215. The LANMAN 1.0 server nodes send  the  following  Mail  Slot
  6216. Transaction protocol (announcement form) as a datagram (SEND
  6217. DATAGRAM to an installation determined group name)  periodi-
  6218. cally to inform consumer nodes that the server exists and is
  6219. ready to accept VC connection requests.
  6220.  
  6221. The LANMAN 1.0 consumer nodes send the following  Mail  Slot
  6222. Transaction  protocol  (announce request form) as a datagram
  6223. (SEND DATAGRAM to an installation determined group name)  to
  6224. request  that server nodes available identify themselves via
  6225. the announcement Transaction datagram.
  6226.  
  6227. Note that the Mail Slot transaction name  "\MAILSLOT\LANMAN"
  6228. is reserved for use by the LAN Manager.
  6229.  
  6230. The default group name used by LANMAN 1.0 is "LANGROUP".
  6231.  
  6232. Also note that there is no "security"  involved  with  these
  6233. protocols.  The smb_tid and smb_uid fields will be set to -1
  6234. and will be ignored by the node receiving this  transaction.
  6235. Each node may apply its own security mechanisms to determine
  6236. whether to reply to (or send) these protocols.
  6237.  
  6238.  
  6239. Announce Mail Slot Transaction format:
  6240.  
  6241.   BYTE   smb_wct;       /* value = 17 */
  6242.   WORD   smb_tpscnt;    /* value = 0 no param bytes being sent */
  6243.   WORD   smb_tdscnt;    /* size of announce or req_announce */
  6244.   WORD   smb_mprcnt;    /* value = 0 no param bytes to return (N/A)*/
  6245.   WORD   smb_mdrcnt;    /* value = 0 no data to read from mail slot (N/A)*/
  6246.   BYTE   smb_msrcnt;    /* value = 0 no setup words to return (N/A)*/
  6247.   BYTE   smb_rsvd1;     /* reserved (pad above to word) */
  6248.   WORD   smb_flags;     /* additional information:
  6249.                         bit 0 - 0 N/A
  6250.                         bit 1 - set, no response is required (value = 1) */
  6251.  DWORD   smb_timeout;   /* (user defined) number of milliseconds to wait */
  6252.   WORD   smb_rsvd;      /* reserved */
  6253.   WORD   smb_pscnt;     /* value = 0 no parameter bytes being sent this buf */
  6254.   WORD   smb_psoff;     /* value = 0 no parameter bytes */
  6255.   WORD   smb_dscnt;     /* size of announce or req_announce */
  6256.   WORD   smb_dsoff;     /* offset (from start of SMB hdr) to data bytes */
  6257.   BYTE   smb_suwcnt;    /* value = 3 */
  6258.   BYTE   smb_rsvd2;     /* reserved (pad above to word) */
  6259.   WORD   smb_setup1;    /* (op code) value = 1 - Write Mail slot */
  6260.   WORD   smb_setup2;    /* (priority) priority of transaction */
  6261.   WORD   smb_setup3;    /* (class) 2 = unreliable */
  6262.   WORD   smb_bcc;       /* total bytes (including pad bytes) following */
  6263.   BYTE   smb_name[];    /* "\MAILSLOT\LANMAN" (null terminated string) */
  6264.   BYTE   smb_pad[];     /* (optional) to pad to word or dword boundary */
  6265.  
  6266.  
  6267.  
  6268. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  6269.  
  6270.  
  6271.  
  6272.  
  6273.  
  6274. SMB Protocol Extensions    - 96 -           November 7, 1988
  6275.  
  6276.  
  6277.   BYTE   smb_data[*];   /* (announce or req_announce structure)
  6278.                            (* = value of smb_dscnt) */
  6279.  
  6280.  
  6281.  
  6282. Announcement Structure Format:
  6283.  
  6284.   WORD   op_code;       /* value = 1 (announce) */
  6285.  DWORD   services;      /* may both be set
  6286.                         bit 0 - work station
  6287.                         bit 1 - server */
  6288.   BYTE   vers_major;    /* major version number of node software */
  6289.   BYTE   vers_minor;    /* minor version number of node software */
  6290.   WORD   periodicity;   /* announcement cycle in seconds */
  6291.   BYTE   node_name[];   /* computer name of this node */
  6292.   BYTE   comment[];     /* descriptive remark */
  6293.  
  6294.  
  6295.  
  6296. Request Announce Structure Format:
  6297.  
  6298.   WORD   op_code;       /* value = 2 (request announce) */
  6299.   BYTE   node_name[];   /* computer name of this node */
  6300.  
  6301.  
  6302.  
  6303.  
  6304.  
  6305.  
  6306.  
  6307.  
  6308.  
  6309.  
  6310.  
  6311.  
  6312.  
  6313.  
  6314.  
  6315.  
  6316.  
  6317.  
  6318.  
  6319.  
  6320.  
  6321.  
  6322.  
  6323.  
  6324.  
  6325.  
  6326.  
  6327.  
  6328.  
  6329.  
  6330.  
  6331.  
  6332.  
  6333.  
  6334. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  6335.  
  6336.  
  6337.  
  6338.  
  6339.  
  6340. SMB Protocol Extensions    - 97 -           November 7, 1988
  6341.  
  6342.  
  6343. 9.2.17.1.3.  Named pipe Transaction protocol
  6344.  
  6345.  
  6346. Named pipes require reliable delivery, thus this Transaction
  6347. protocol is sent/received only on an established VC.
  6348.  
  6349. A named pipe transaction is used to wait for  the  specified
  6350. named  pipe  to  become  available (WaitNmPipe) or perform a
  6351. logical "open ->  write  ->  read  ->  close"  of  the  pipe
  6352. (CallNmPipe), along with other functions defined below.
  6353.  
  6354. Other Standard protocols (Open, Read,  Write,  Close,  etc.)
  6355. may  also  be  used to access Named pipes when pipe is being
  6356. accessed like a "standard" file  (a  file  handle  is  being
  6357. used).
  6358.  
  6359. The identifier "\PIPE\<name>" denotes a named pipe  transac-
  6360. tion,  where  the <name> is the pipe name to apply the tran-
  6361. saction against.
  6362.  
  6363. Note that the named pipe transaction name "\PIPE\LANMAN"  is
  6364. reserved for use by the LAN Manager.
  6365.  
  6366.  
  6367.  
  6368.   BYTE   smb_wct;        /* value = 16 */
  6369.   WORD   smb_tpscnt;     /* total number of parameter bytes being sent */
  6370.   WORD   smb_tdscnt;     /* size of data to be written to pipe (if any) */
  6371.   WORD   smb_mprcnt;     /* max number of parameter bytes to return */
  6372.   WORD   smb_mdrcnt;     /* size of data to be read from pipe (if any) */
  6373.   BYTE   smb_msrcnt;     /* value = 0 max number of setup words to return */
  6374.   BYTE   smb_rsvd;       /* reserved (pad above to word) */
  6375.   WORD   smb_flags;      /* additional information:
  6376.                          bit 0 - if set, also disconnect TID in smb_tid
  6377.                          bit 1 - not set, response is required */
  6378.  DWORD   smb_timeout;    /* (user defined) number of milliseconds to wait */
  6379.   WORD   smb_rsvd1;      /* reserved */
  6380.   WORD   smb_pscnt;      /* number of parameter bytes being sent this buffer */
  6381.   WORD   smb_psoff;      /* offset (from start of SMB hdr) to parameter bytes */
  6382.   WORD   smb_dscnt;      /* number of data bytes being sent this buffer */
  6383.   WORD   smb_dsoff;      /* offset (from start of SMB hdr) to data bytes */
  6384.   BYTE   smb_suwcnt;     /* value = 2 */
  6385.   BYTE   smb_rsvd2;      /* reserved (pad above to word) */
  6386.   WORD   smb_setup1;     /* function (defined below)
  6387.                           0x54 - CallNmPipe - open/write/read/close pipe
  6388.                           0x53 - WaitNmPipe - wait for pipe to be nonbusy
  6389.                           0x23 - PeekNmPipe - read but don't remove data
  6390.                           0x21 - QNmPHandState - query pipe handle modes
  6391.                           0x01 - SetNmPHandState - set pipe handle modes
  6392.                           0x22 - QNmPipeInfo - query pipe attributes
  6393.                           0x26 - TransactNmPipe - write/read operation on pipe
  6394.                           0x11 - RawReadNmPipe - read pipe in "raw" (non message mode)
  6395.                           0x31 - RawWriteNmPipe - write pipe "raw" (non message mode) */
  6396.   WORD   smb_setup2;     /* FID (handle) of pipe (if needed), or priority */
  6397.  
  6398.  
  6399.  
  6400. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  6401.  
  6402.  
  6403.  
  6404.  
  6405.  
  6406. SMB Protocol Extensions    - 98 -           November 7, 1988
  6407.  
  6408.  
  6409.   WORD   smb_bcc;        /* total bytes (including pad bytes) following */
  6410.   BYTE   smb_name[];     /* "\PIPE\<name>0"  */
  6411.   BYTE   smb_pad[];      /* (optional) to pad to word or dword boundary */
  6412.   BYTE   smb_param[*];   /* param bytes (* = value of smb_prcnt) */
  6413.   BYTE   smb_pad1[];     /* (optional) to pad to word or dword boundary */
  6414.   BYTE   smb_data[*];    /* data bytes (* = value of smb_drcnt) */
  6415.  
  6416.  
  6417.  
  6418.  
  6419.  
  6420.  
  6421.  
  6422.  
  6423.  
  6424.  
  6425.  
  6426.  
  6427.  
  6428.  
  6429.  
  6430.  
  6431.  
  6432.  
  6433.  
  6434.  
  6435.  
  6436.  
  6437.  
  6438.  
  6439.  
  6440.  
  6441.  
  6442.  
  6443.  
  6444.  
  6445.  
  6446.  
  6447.  
  6448.  
  6449.  
  6450.  
  6451.  
  6452.  
  6453.  
  6454.  
  6455.  
  6456.  
  6457.  
  6458.  
  6459.  
  6460.  
  6461.  
  6462.  
  6463.  
  6464.  
  6465.  
  6466. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  6467.  
  6468.  
  6469.  
  6470.  
  6471.  
  6472. SMB Protocol Extensions    - 99 -           November 7, 1988
  6473.  
  6474.  
  6475. 9.2.17.1.3.  CallNmPipe
  6476.  
  6477.  
  6478. This protocol is used to implement DosCallNmPipe remotely.
  6479.  
  6480. This transaction has the combined effect on a named pipe  of
  6481. Open,  Transact  NmPipe, Close. It provides a very efficient
  6482. means of implementing Remote Procedure Call (RPC) interfaces
  6483. between processes.
  6484.  
  6485. This form of the transaction  protocol  sends  no  parameter
  6486. bytes,  thus the bytes to be written to the pipe are sent as
  6487. data bytes (smb_databytes) and the bytes read from the  pipe
  6488. are returned as data bytes (smb_databytes).
  6489.  
  6490. The number of bytes being written is  defined  by  smb_dscnt
  6491. and  the  max  number  of  bytes  to  return  is  defined by
  6492. smb_drcnt.
  6493.  
  6494. On the response smb_rprcnt is 0 (no param bytes to  return),
  6495. smb_rdrcnt  indicates the amount of databytes being returned
  6496. in total and smb_bcc identifies the  amount  of  data  being
  6497. retuned in each buffer.
  6498.  
  6499. Note that the full form of the Transaction protocol  can  be
  6500. used to write and read up to 65,535 bytes each utilizing the
  6501. secondary requests and responses.
  6502.  
  6503. CallNmPipe uses priority in smb_setup2.  The priority values
  6504. range  from  0 (use server default) to 0x3FF (highest prior-
  6505. ity).  The priority passed in smb_setup2 from a LANMAN  con-
  6506. sumer  will  be the value as returned from a DosGetPrty OS/2
  6507. system call.  The server may use the priority in determining
  6508. which process to run next when a pipe becomes available.
  6509.  
  6510.  
  6511.  
  6512.  
  6513.  
  6514.  
  6515.  
  6516.  
  6517.  
  6518.  
  6519.  
  6520.  
  6521.  
  6522.  
  6523.  
  6524.  
  6525.  
  6526.  
  6527.  
  6528.  
  6529.  
  6530.  
  6531.  
  6532. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  6533.  
  6534.  
  6535.  
  6536.  
  6537.  
  6538. SMB Protocol Extensions   - 100 -           November 7, 1988
  6539.  
  6540.  
  6541. 9.2.17.1.3.  WaitNmPipe
  6542.  
  6543.  
  6544. This form of the pipe Transaction  protocol  waits  for  the
  6545. availability of a named pipe instance.  It is used to imple-
  6546. ment the DosWaitNmPipe call on a remote pipe.
  6547.  
  6548. DosWaitNmPipe allows an application to wait for a pipe  when
  6549. all  available  instances are currently busy.  This protocol
  6550. may be used when the error ERRpipebusy is  returned  from  a
  6551. Open (pipe) protocol attempt.
  6552.  
  6553. The server will wait up to smb_timeout  milliseconds  for  a
  6554. pipe  of  the  name  given  to  become available.  Note that
  6555. although the timeout is specified in milliseconds (in  order
  6556. to  match  the  OS/2  system  calls),  by  the time that the
  6557. timeout occurs and the consumer receives the timed out  pro-
  6558. tocol much more time than specified may have occurred.
  6559.  
  6560. This form of the  transaction  protocol  sends  no  data  or
  6561. parameter  bytes.   The  response  also  contains no data or
  6562. parameters.  If smb_err is 0, the requested named  pipe  may
  6563. now be available.
  6564.  
  6565. Note that this protocol does NOT reserve the pipe, thus  all
  6566. waiting  programs  may  race  to get the pipe now available.
  6567. The loosers will again get ERRpipebusy on the Open attempt.
  6568.  
  6569. WaitNmPipe uses priority in smb_setup2.  The priority values
  6570. range  from  0 (use server default) to 0x3FF (highest prior-
  6571. ity).  The priority passed in smb_setup2 from a LANMAN  con-
  6572. sumer  will  be the value as returned from a DosGetPrty OS/2
  6573. system call.  The server may use the priority in determining
  6574. which process to notify when a pipe becomes available.
  6575.  
  6576.  
  6577.  
  6578.  
  6579.  
  6580.  
  6581.  
  6582.  
  6583.  
  6584.  
  6585.  
  6586.  
  6587.  
  6588.  
  6589.  
  6590.  
  6591.  
  6592.  
  6593.  
  6594.  
  6595.  
  6596.  
  6597.  
  6598. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  6599.  
  6600.  
  6601.  
  6602.  
  6603.  
  6604. SMB Protocol Extensions   - 101 -           November 7, 1988
  6605.  
  6606.  
  6607. 9.2.17.1.3.  PeekNmPipe
  6608.  
  6609.  
  6610. This form of the pipe Transaction protocol is used to imple-
  6611. ment DosPeekNmPipe remotely.
  6612.  
  6613. Purpose:  Read pipe without removing the read data from  the
  6614. pipe.
  6615.  
  6616. PeekNmPipe acts like Read except as follows:
  6617.  
  6618.  
  6619. 0    The bytes read are not removed from the pipe.
  6620.  
  6621.  
  6622. 0    The peek may return only part of a message  (that  part
  6623.      currently  in  the  pipe), even if the size of the peek
  6624.      would accommodate the whole message.
  6625.  
  6626.  
  6627. 0    PeekNmPipe never blocks,  regardless  of  the  blocking
  6628.      mode.
  6629.  
  6630.  
  6631. 0    Additional information about the status of the pipe and
  6632.      remaining  data are returned.  The caller can use this,
  6633.      for example, to determine whether the peek returned all
  6634.      of  the  current  message or whether the pipe is at EOF
  6635.      (pipe is at EOF when there are no  bytes  left  in  the
  6636.      pipe and Status is Closing or Disconnected).
  6637.  
  6638.      The request form of this protocol should set  smb_pscnt
  6639.      to 0.  The pipe handle being "peek'ed" should be set in
  6640.      smb_setup2.  smb_dscnt should be set to 0 (not  writing
  6641.      data  to pipe).  smb_prcnt should be set to 6 (request-
  6642.      ing the 3 words of  information  about  the  pipe)  and
  6643.      smb_drcnt set to the number of bytes to "peek".
  6644.  
  6645.      The response will return the 3 parameters (smb_rprcnt =
  6646.      6),  smb_rdrcnt  will  be  set  to  the number of bytes
  6647.      "peek'ed" and smb_bcc will be set to  6  (the  3  param
  6648.      words) + the amount of data bytes being returned in the
  6649.      first  buffer.    Subsequent   responses   would   have
  6650.      smb_rprcnt  set  to 0, smb_rdrcnt set to the data bytes
  6651.      remaining and smb_bcc indicating  the  number  of  data
  6652.      bytes being returned in each buffer.
  6653.  
  6654.      The following  defines  the  format  of  the  parameter
  6655.      words.
  6656.  
  6657.  
  6658.  
  6659.  
  6660.  
  6661.  
  6662.  
  6663.  
  6664. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  6665.  
  6666.  
  6667.  
  6668.  
  6669.  
  6670. SMB Protocol Extensions   - 102 -           November 7, 1988
  6671.  
  6672.  
  6673.  
  6674.                  WORD    bytes remaining in the pipe
  6675.  
  6676.                  WORD    bytes remaining in current message
  6677.  
  6678.                  WORD    pipe status
  6679.                            1 - Disconnected (disconnected by server)
  6680.                            2 - Listening (N/A not returned on consumer end of pipe)
  6681.                            3 - Connected (connection to server OK)
  6682.                            4 - Closing (server end of pipe closed)
  6683.  
  6684.  
  6685.  
  6686.  
  6687.  
  6688.  
  6689.  
  6690.  
  6691.  
  6692.  
  6693.  
  6694.  
  6695.  
  6696.  
  6697.  
  6698.  
  6699.  
  6700.  
  6701.  
  6702.  
  6703.  
  6704.  
  6705.  
  6706.  
  6707.  
  6708.  
  6709.  
  6710.  
  6711.  
  6712.  
  6713.  
  6714.  
  6715.  
  6716.  
  6717.  
  6718.  
  6719.  
  6720.  
  6721.  
  6722.  
  6723.  
  6724.  
  6725.  
  6726.  
  6727.  
  6728.  
  6729.  
  6730. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  6731.  
  6732.  
  6733.  
  6734.  
  6735.  
  6736. SMB Protocol Extensions   - 103 -           November 7, 1988
  6737.  
  6738.  
  6739. 9.2.17.1.3.  QNmPHandState
  6740.  
  6741.  
  6742. This form of the pipe Transaction protocol is used to imple-
  6743. ment DosQNmPHandState remotely.
  6744.  
  6745. Purpose:  Return pipe-specific state information.
  6746.  
  6747. The request form of this protocol should set smb_pscnt to  0
  6748. (no  parameters)  The  pipe  handle should be in smb_setup2.
  6749. smb_dscnt should be set to 0 (not  writing  data  to  pipe).
  6750. smb_prcnt  should  be  set  to  2  (requesting the 1 word of
  6751. information about the pipe) and  smb_drcnt  set  to  0  (not
  6752. reading the pipe).
  6753.  
  6754. The response will return the 1 parameter (smb_rprcnt = 1) of
  6755. pipe state information.
  6756.  
  6757.  
  6758.  
  6759. Pipe Handle State Bits
  6760.       5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  6761.       B E * * T T R R |--- Icount --|
  6762. where:
  6763.       B - Blocking - 0 =>  reads/writes  block  if  no  data
  6764. available
  6765.                          1 =>  reads/writes  return  immedi-
  6766. ately if no data
  6767.       E - Endpoint - 0 => consumer end of pipe
  6768.                          1 => server end of pipe
  6769.       TT - Type of pipe - 00 => pipe is a byte stream pipe
  6770.                               01 => pipe is a message pipe
  6771.       RR - Read Mode - 00 => Read pipe as a byte stream
  6772.                            01 => Read messages from pipe
  6773.       Icount - 8-bit count to control pipe instancing (N/A)
  6774.  
  6775.  
  6776. The E (endpoint) bit is 0 because this handle is the  client
  6777. end of a pipe.
  6778.  
  6779. The values returned are those originally established by Open
  6780. or a subsequent SetNmPHandState.
  6781.  
  6782.  
  6783.  
  6784.  
  6785.  
  6786.  
  6787.  
  6788.  
  6789.  
  6790.  
  6791.  
  6792.  
  6793.  
  6794.  
  6795.  
  6796. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  6797.  
  6798.  
  6799.  
  6800.  
  6801.  
  6802. SMB Protocol Extensions   - 104 -           November 7, 1988
  6803.  
  6804.  
  6805. 9.2.17.1.3.  SetNmPHandState
  6806.  
  6807.  
  6808. This form of the pipe Transaction protocol is used to imple-
  6809. ment DosSetNmPHandState remotely.
  6810.  
  6811. Purpose:  Set pipe-specific handle states.
  6812.  
  6813. The request form of this protocol should set smb_pscnt to  2
  6814. (one  word  parameter,  the pipe state to be set).  The pipe
  6815. handle should be in smb_setup2.  smb_dscnt should be set  to
  6816. 0  (not writing data to pipe).  smb_prcnt should be set to 0
  6817. and smb_drcnt set to 0 (not reading the pipe).
  6818.  
  6819. The response contains no data or parameters.  If smb_err  is
  6820. 0, the requested state has been set on the pipe.
  6821.  
  6822.  
  6823.  
  6824. Pipe Handle State Bits
  6825.       5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  6826.       B * * * * * R R 0 0 0 0 0 0 0 0
  6827. where:
  6828.       B - Blocking - 0 =>  reads/writes  block  if  no  data
  6829. available
  6830.                          1 =>  reads/writes  return  immedi-
  6831. ately if no data
  6832.       RR - Read Mode - 00 => Read pipe as a byte stream
  6833.                            01 => Read messages from pipe
  6834.  
  6835.  
  6836. Note  that  only  the  read  mode  (byte  vrs  message)  and
  6837. blocking/nonblocking  mode  of  a named pipe can be changed.
  6838. Some combinations of parameters may be illegal and  will  be
  6839. rejected as an error.
  6840.  
  6841.  
  6842.  
  6843.  
  6844.  
  6845.  
  6846.  
  6847.  
  6848.  
  6849.  
  6850.  
  6851.  
  6852.  
  6853.  
  6854.  
  6855.  
  6856.  
  6857.  
  6858.  
  6859.  
  6860.  
  6861.  
  6862. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  6863.  
  6864.  
  6865.  
  6866.  
  6867.  
  6868. SMB Protocol Extensions   - 105 -           November 7, 1988
  6869.  
  6870.  
  6871. 9.2.17.1.3.  QNmPipeInfo
  6872.  
  6873.  
  6874. This form of the pipe Transaction protocol is used to imple-
  6875. ment DosQNmPipeInfo remotely.
  6876.  
  6877. Purpose:  Returns information about a pipe
  6878.  
  6879. The request form of this protocol should set smb_pscnt to  2
  6880. (one  word parameter, the information level).  The pipe han-
  6881. dle should be in smb_setup2.  smb_drcnt should be set to the
  6882. size  specified  by  the  user  in which to receive the pipe
  6883. information.  smb_dscnt should be set to 0 and smb_prcnt set
  6884. to 0.
  6885.  
  6886. Pipe information  is  returned  in  the  data  area  of  the
  6887. response, up to the number of bytes specified.  The informa-
  6888. tion is returned in the following format:
  6889.  
  6890.  
  6891.         LEVEL 1:
  6892.  
  6893.             WORD    actual size of buffer for outgoing (server) I/O
  6894.  
  6895.             WORD    actual size of buffer for incoming (consumer) I/O
  6896.  
  6897.             BYTE    Maximum allowed number of instances
  6898.  
  6899.             BYTE    Current number of instances
  6900.  
  6901.             BYTE    Length of pipe name (including the null)
  6902.  
  6903.             ASCIZ    Name of pipe (NOT including \\NodeName - \\NodeName
  6904.                      is prepended to this string by the consumer before passing
  6905.                      back to the user)
  6906.  
  6907.         LEVEL 2:
  6908.  
  6909.             (TBD)
  6910.  
  6911.  
  6912.  
  6913.  
  6914.  
  6915.  
  6916.  
  6917.  
  6918.  
  6919.  
  6920.  
  6921.  
  6922.  
  6923.  
  6924.  
  6925.  
  6926.  
  6927.  
  6928. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  6929.  
  6930.  
  6931.  
  6932.  
  6933.  
  6934. SMB Protocol Extensions   - 106 -           November 7, 1988
  6935.  
  6936.  
  6937. 9.2.17.1.3.  TransactNmPipe
  6938.  
  6939.  
  6940. This form of the pipe Transaction protocol is used to imple-
  6941. ment DosTransactNmPipe remotely.
  6942.  
  6943. Purpose:  Combine a read and  write  operation  on  a  named
  6944. pipe.
  6945.  
  6946. TransactNmPipe performs a write followed by a read on a mes-
  6947. sage pipe.
  6948.  
  6949. It provides an optimum way to implement transaction-oriented
  6950. dialogs.   TransactNmPipe  will  fail  if the pipe currently
  6951. contains any unread data or is not  in  message  read  mode.
  6952. Otherwise  the call will write the entire request data bytes
  6953. to the pipe and then read  a  response  from  the  pipe  and
  6954. return  it  in the data bytes area of the response protocol.
  6955. In the transaction request, smb_setup2  should  contain  the
  6956. pipe handle.
  6957.  
  6958. The state of blocking/nonblocking has no effect on this pro-
  6959. tocol  (TransactNmPipe  does  not return until a message has
  6960. been read into the response protocol).  If smb_drcnt is  too
  6961. small  to  contain the response message, ERRmoredata will be
  6962. returned.
  6963.  
  6964.  
  6965.  
  6966.  
  6967.  
  6968.  
  6969.  
  6970.  
  6971.  
  6972.  
  6973.  
  6974.  
  6975.  
  6976.  
  6977.  
  6978.  
  6979.  
  6980.  
  6981.  
  6982.  
  6983.  
  6984.  
  6985.  
  6986.  
  6987.  
  6988.  
  6989.  
  6990.  
  6991.  
  6992.  
  6993.  
  6994. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  6995.  
  6996.  
  6997.  
  6998.  
  6999.  
  7000. SMB Protocol Extensions   - 107 -           November 7, 1988
  7001.  
  7002.  
  7003. 9.2.17.1.3.  RawReadNmPipe
  7004.  
  7005.  
  7006. This form of the pipe Transaction protocol is used to imple-
  7007. ment DosRawReadNmPipe remotely.
  7008.  
  7009. Purpose:  Read a named pipe without removing record informa-
  7010. tion.
  7011.  
  7012. RawReadNmPipe reads bytes directly from a  pipe,  regardless
  7013. of  whether  it is a message or byte pipe.  For a byte pipe,
  7014. this is exactly like Read.  For  a  message  pipe,  this  is
  7015. exactly like reading the pipe in byte read mode, except mes-
  7016. sage headers will also be returned in the buffer (note  that
  7017. message headers will always be returned in toto--never split
  7018. at a byte boundary).
  7019.  
  7020. The request form of this protocol should set smb_pscnt to 0.
  7021. The   pipe   handle  being  "read  raw"  should  be  set  in
  7022. smb_setup2.  smb_dscnt should be set to 0 (not writing  data
  7023. to  pipe).   smb_prcnt should be set to 0  and smb_drcnt set
  7024. to the number of bytes to "read raw".
  7025.  
  7026. The response will return  0  parameters  (smb_rprcnt  =  0),
  7027. smb_rdrcnt will be set to the number of bytes "read raw" and
  7028. smb_bcc will be set  to  the  amount  of  data  bytes  being
  7029. returned  in  the  first buffer.  Subsequent responses would
  7030. have smb_rprcnt set to 0, smb_rdrcnt set to the  data  bytes
  7031. remaining  and  smb_bcc  indicating the number of data bytes
  7032. being returned in each buffer.
  7033.  
  7034.  
  7035.  
  7036.  
  7037.  
  7038.  
  7039.  
  7040.  
  7041.  
  7042.  
  7043.  
  7044.  
  7045.  
  7046.  
  7047.  
  7048.  
  7049.  
  7050.  
  7051.  
  7052.  
  7053.  
  7054.  
  7055.  
  7056.  
  7057.  
  7058.  
  7059.  
  7060. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  7061.  
  7062.  
  7063.  
  7064.  
  7065.  
  7066. SMB Protocol Extensions   - 108 -           November 7, 1988
  7067.  
  7068.  
  7069. 9.2.17.1.3.  RawWriteNmPipe
  7070.  
  7071.  
  7072. This form of the pipe Transaction protocol is used to imple-
  7073. ment DosRawWriteNmPipe remotely.
  7074.  
  7075. Purpose:  Write a named pipe without adding record  informa-
  7076. tion.
  7077.  
  7078. RawWriteNmPipe puts bytes directly into a  pipe,  regardless
  7079. of  whether  it  is  a  message or byte pipe.  The data will
  7080. include message headers if it is a message pipe.  This  call
  7081. ignores  the blocking/nonblocking state and always acts in a
  7082. blocking manner. It returns only after all bytes  have  been
  7083. written.
  7084.  
  7085. The request form of this protocol should set smb_pscnt to 0.
  7086. The  pipe  handle  being  "written  raw"  should  be  set in
  7087. smb_setup2.  smb_dscnt should be set  to  the  total  amount
  7088. "writing raw" to the pipe.  smb_prcnt should be set to 2 and
  7089. smb_drcnt set 0.
  7090.  
  7091. The response contains no data and  one  parameter  word.  If
  7092. smb_err is 0, the one parameter word indicates the number of
  7093. the requested bytes that have  been  "written  raw"  to  the
  7094. specified pipe.
  7095.  
  7096.  
  7097.  
  7098.  
  7099.  
  7100.  
  7101.  
  7102.  
  7103.  
  7104.  
  7105.  
  7106.  
  7107.  
  7108.  
  7109.  
  7110.  
  7111.  
  7112.  
  7113.  
  7114.  
  7115.  
  7116.  
  7117.  
  7118.  
  7119.  
  7120.  
  7121.  
  7122.  
  7123.  
  7124.  
  7125.  
  7126. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  7127.  
  7128.  
  7129.  
  7130.  
  7131.  
  7132. SMB Protocol Extensions   - 109 -           November 7, 1988
  7133.  
  7134.  
  7135. 9.2.18.  TREE CONNECT and X
  7136.  
  7137. Request Format:
  7138.  
  7139.   BYTE   smb_wct;          /* value = 4 */
  7140. + BYTE   smb_com2;         /* secondary (X) command, 0xFF = none */
  7141. + BYTE   smb_reh2;         /* reserved (must be zero) */
  7142. + WORD   smb_off2;         /* offset (from SMB hdr start) to next cmd (@smb_wct) */
  7143. + WORD   smb_flags;        /* additional information:
  7144.                            bit 0 - if set, disconnect TID in current smb_tid */
  7145. + WORD   smb_spasslen;     /* length of smb_spasswd */
  7146.   WORD   smb_bcc;          /* minimum value = 3 */
  7147.   BYTE   smb_spasswd[*];   /* net-name password (* = smb_spasslen value) */
  7148.   BYTE   smb_path[];       /* server name and net-name */
  7149.   BYTE   smb_dev[];        /* service name string */
  7150.  
  7151. + Additional parameters (compared  with  core  TREE  CONNECT
  7152. protocol)
  7153.  
  7154. Response Format:
  7155.  
  7156.   BYTE   smb_wct;         /* value = 2 */
  7157. + BYTE   smb_com2;        /* secondary (X) command, 0xFF = none */
  7158. + BYTE   smb_res2;        /* reserved (pad to word) */
  7159. + WORD   smb_off2;        /* offset (from SMB hdr start) to next cmd (@smb_wct) */
  7160.   WORD   smb_bcc;         /* min value = 3 */
  7161. + BYTE   smb_service[];   /* service type connected to (string) */
  7162.  
  7163. + Additional parameters (compared  with  core  TREE  CONNECT
  7164. protocol)
  7165.  
  7166. Service Enhancement:
  7167.  
  7168. Because the password may be  encrypted,  it  is  a  variable
  7169. length  field  with the length specified by smb_spasslen (if
  7170. password encryption is not being used, smb_spasswd should be
  7171. a  null terminated ASCII string with smb_spasslen set to the
  7172. string size including the null).
  7173.  
  7174.  
  7175. The service name in the request (smb_dev) may now include:
  7176.  
  7177.  
  7178.  
  7179.  
  7180.  
  7181.  
  7182.  
  7183.  
  7184.  
  7185.  
  7186.  
  7187.  
  7188.  
  7189.  
  7190.  
  7191.  
  7192. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  7193.  
  7194.  
  7195.  
  7196.  
  7197.  
  7198. SMB Protocol Extensions   - 110 -           November 7, 1988
  7199.  
  7200.  
  7201.  
  7202.           o  A: - for file service
  7203.  
  7204.           o  LPT1: - for a spooled output (DOS standard LPT or COM) service
  7205.  
  7206.           o  COMM - for direct access communication device service or
  7207.                     direct access printer device service
  7208.  
  7209.           o  IPC - for inter-process communication services (named pipes, etc.)
  7210.  
  7211.           o  ????? - "Wild card" indicating that the consumer does not yet know
  7212.              the type of service shared with the given netname and would
  7213.              like the service type returned in the smb_service string of the response.
  7214.  
  7215.  
  7216.  
  7217. The smb_service string returned should be one of  the  above
  7218. service names.
  7219.  
  7220.  
  7221. The entire message sent and received including the  optional
  7222. second  protocol  must  fit  in  the negotiated max transfer
  7223. size.
  7224.  
  7225. If the tree disconnect fails, the error should be ignored.
  7226.  
  7227. The following are the only valid protocol requests  commands
  7228. for smb_com2 (X) for TREE CONNECT and X:
  7229.  
  7230.         OPEN FILE
  7231.         OPEN and X
  7232.         CREATE FILE
  7233.         MAKE NEW FILE
  7234.         CREATE DIRECTORY
  7235.         DELETE FILE
  7236.         DELETE DIRECTORY
  7237.         FILE SEARCH
  7238.         FIND
  7239.         FIND UNIQUE
  7240.         COPY FILE
  7241.         RENAME FILE
  7242.         MOVE FILE
  7243.         CHECK PATH
  7244.         GET FILE ATTRIBUTES
  7245.         SET FILE ATTRIBUTES
  7246.         GET SERVER ATTRIBUTES
  7247.         QUERY SERVER INFO
  7248.         CREATE PRINT FILE
  7249.         GET PRINT QUEUE
  7250.         TRANSACTION
  7251.  
  7252.  
  7253. Tree Connect and X may generate the following errors.
  7254.  
  7255.  
  7256.  
  7257.  
  7258. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  7259.  
  7260.  
  7261.  
  7262.  
  7263.  
  7264. SMB Protocol Extensions   - 111 -           November 7, 1988
  7265.  
  7266.  
  7267.  
  7268.         Error Class ERRDOS
  7269.  
  7270.           <implementation specific>
  7271.  
  7272.  
  7273.         Error Class ERRSRV
  7274.  
  7275.           ERRerror
  7276.           ERRbadpw
  7277.           ERRinvnetname
  7278.           <implementation specific>
  7279.  
  7280.  
  7281.         Error Class ERRHRD
  7282.  
  7283.           <implementation specific>
  7284.  
  7285.  
  7286.  
  7287.  
  7288.  
  7289.  
  7290.  
  7291.  
  7292.  
  7293.  
  7294.  
  7295.  
  7296.  
  7297.  
  7298.  
  7299.  
  7300.  
  7301.  
  7302.  
  7303.  
  7304.  
  7305.  
  7306.  
  7307.  
  7308.  
  7309.  
  7310.  
  7311.  
  7312.  
  7313.  
  7314.  
  7315.  
  7316.  
  7317.  
  7318.  
  7319.  
  7320.  
  7321.  
  7322.  
  7323.  
  7324. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  7325.  
  7326.  
  7327.  
  7328.  
  7329.  
  7330. SMB Protocol Extensions   - 112 -           November 7, 1988
  7331.  
  7332.  
  7333. 9.2.19.  WRITE and CLOSE
  7334.  
  7335. Request Format (same length as core WRITE or  extended  WRI-
  7336. TEandX):
  7337.  
  7338.   BYTE   smb_wct;      /* value = 6 OR 12) */
  7339.   WORD   smb_fid;      /* file handle (close after write) */
  7340.   WORD   smb_count;    /* number of bytes to write */
  7341.  DWORD   smb_offset;   /* offset in file to begin write */
  7342.  DWORD   smb_mtime;    /* modification time */
  7343.  DWORD   smb_rsvd1;    /* Optional */
  7344.  DWORD   smb_rsvd1;    /* Optional */
  7345.  DWORD   smb_rsvd1;    /* Optional */
  7346.   WORD   smb_bcc;      /* 1 (for pad) + value of smb_count */
  7347.   BYTE   smb_pad;      /* force data to dword boundary */
  7348.   BYTE   smb_data[];   /* data */
  7349.  
  7350.  
  7351.  
  7352. Response Format (same as core WRITE):
  7353.  
  7354.   BYTE   smb_wct;     /* value = 1 */
  7355.   WORD   smb_count;   /* number of bytes written */
  7356.   WORD   smb_bcc;     /* value = 0 */
  7357.  
  7358.  
  7359. Service:
  7360.  
  7361. The Write and Close request  is  used  to  first  write  the
  7362. specified bytes and then close the file.
  7363.  
  7364. Buffered write behind data (and read ahead data) is commonly
  7365. kept  in  a  buffer  also containing space for the Write SMB
  7366. protocol.  This protocol allows the final write behind  data
  7367. to  be  flushed when the file is closed with a single proto-
  7368. col.
  7369.  
  7370. NOTE - the smb_wct field MUST be used in order to  correctly
  7371. locate the data to be written.
  7372.  
  7373. This protocol may be the same length (smb_wct =  6)  as  the
  7374. "core" Write request protocol such that the buffered data is
  7375. in the correct position and  only  the  smb_header  need  be
  7376. changed  to  cause  the final bytes to be written along with
  7377. the file close. This is efficient  if  the  data  were  read
  7378. using  the  "core" read protocol.  Note that the "core" Read
  7379. response protocol is this same  size  as  the  "core"  write
  7380. request  protocol  and  the  "extended" "WriteandUnlock" and
  7381. "LockandRead" protocols defined in this document.
  7382.  
  7383. Alternately,  this protocol may be the same length  (smb_wct
  7384. =  12)  as  the  "extended" WriteandX protocol such that the
  7385. buffered data is  in  the  correct  position  and  only  the
  7386. smb_header  need  be  changed to cause the final bytes to be
  7387.  
  7388.  
  7389.  
  7390. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  7391.  
  7392.  
  7393.  
  7394.  
  7395.  
  7396. SMB Protocol Extensions   - 113 -           November 7, 1988
  7397.  
  7398.  
  7399. written along with the file close. This is efficient if  the
  7400. data were read using the "extended" ReadandX protocol.  Note
  7401. that the "extended" ReadandX response protocol is this  same
  7402. size  as  the  "extended"  WriteandX request defined in this
  7403. document.
  7404.  
  7405. If an error occurs on the write, the file  should  still  be
  7406. closed.
  7407.  
  7408. The  server  should  "spin"  writing   all   data   to   the
  7409. file/pipe/device before doing the close.
  7410.  
  7411. Write and Close may generate the following errors:
  7412.  
  7413.         Error Class ERRDOS:
  7414.  
  7415.           ERRnoaccess
  7416.           ERRbadfid
  7417.           ERRlock
  7418.           ERRbadfiletype
  7419.           ERRbadaccess
  7420.  
  7421.  
  7422.         Error Class ERRSRV:
  7423.  
  7424.           ERRerror
  7425.           ERRinvnid
  7426.           <implementation specific>
  7427.  
  7428.  
  7429.         Error Class ERRHRD:
  7430.  
  7431.           <implementation specific>
  7432.  
  7433.  
  7434.  
  7435.  
  7436.  
  7437.  
  7438.  
  7439.  
  7440.  
  7441.  
  7442.  
  7443.  
  7444.  
  7445.  
  7446.  
  7447.  
  7448.  
  7449.  
  7450.  
  7451.  
  7452.  
  7453.  
  7454.  
  7455.  
  7456. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  7457.  
  7458.  
  7459.  
  7460.  
  7461.  
  7462. SMB Protocol Extensions   - 114 -           November 7, 1988
  7463.  
  7464.  
  7465. 9.2.20.  WRITE and Unlock
  7466.  
  7467. Request Format (same as core WRITE):
  7468.  
  7469.   BYTE   smb_wct;      /* value = 5 */
  7470.   WORD   smb_fid;      /* file handle */
  7471.   WORD   smb_count;    /* number of bytes to write and then unlock */
  7472.  DWORD   smb_offset;   /* offset in file to unlock and begin write */
  7473.   WORD   smb_remcnt;   /* number of bytes remaining to be written */
  7474.   WORD   smb_bcc;      /* minimum value = 3 */
  7475.   BYTE   smb_ident1;   /* value = DATA_BLOCK */
  7476.   WORD   smb_size;     /* length of data being written */
  7477.   BYTE   smb_data[];   /* data */
  7478.  
  7479.  
  7480.  
  7481. Response Format (same as core WRITE):
  7482.  
  7483.   BYTE   smb_wct;     /* value = 1 */
  7484.   WORD   smb_count;   /* number of bytes written */
  7485.   WORD   smb_bcc;     /* value = 0 */
  7486.  
  7487.  
  7488. Service:
  7489.  
  7490. The Write and Unlock request is  used  to  first  write  the
  7491. specified bytes and then unlock them.
  7492.  
  7493. The locked portion of a  file  is  "safe"  to  write  behind
  7494. because  no  other process can access the locked bytes until
  7495. this process unlocks  the  bytes.   Thus  the  consumer  can
  7496. buffer  the  locked  bytes  locally  while  they  are  being
  7497. updated, then when the unlock  request  is  received  submit
  7498. this protocol to both write and then unlock bytes.
  7499.  
  7500. This can provide  significant  performance  improvements  on
  7501. data  base  update  operations  (lock  data  -> read data ->
  7502. [update -> write data] -> unlock data).
  7503.  
  7504. Whether or  not  this  protocol  is  supported  (along  with
  7505. LockandRead)  is  returned in the smb_flg field of the nego-
  7506. tiate response.
  7507.  
  7508. The request and response format are identical  to  the  core
  7509. write.   The  server  merely unlocks the bytes after writing
  7510. them.
  7511.  
  7512. If an error occurs on the write,  the  bytes  should  remain
  7513. locked.
  7514.  
  7515. Write and Unlock may generate the following errors:
  7516.  
  7517.  
  7518.  
  7519.  
  7520.  
  7521.  
  7522. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  7523.  
  7524.  
  7525.  
  7526.  
  7527.  
  7528. SMB Protocol Extensions   - 115 -           November 7, 1988
  7529.  
  7530.  
  7531.  
  7532.         Error Class ERRDOS:
  7533.  
  7534.           ERRnoaccess
  7535.           ERRbadfid
  7536.           ERRlock
  7537.           ERRbadaccess
  7538.  
  7539.  
  7540.         Error Class ERRSRV:
  7541.  
  7542.           ERRerror
  7543.           ERRinvdevice
  7544.           ERRinvnid
  7545.           <implementation specific>
  7546.  
  7547.  
  7548.         Error Class ERRHRD:
  7549.  
  7550.           <implementation specific>
  7551.  
  7552.  
  7553.  
  7554.  
  7555.  
  7556.  
  7557.  
  7558.  
  7559.  
  7560.  
  7561.  
  7562.  
  7563.  
  7564.  
  7565.  
  7566.  
  7567.  
  7568.  
  7569.  
  7570.  
  7571.  
  7572.  
  7573.  
  7574.  
  7575.  
  7576.  
  7577.  
  7578.  
  7579.  
  7580.  
  7581.  
  7582.  
  7583.  
  7584.  
  7585.  
  7586.  
  7587.  
  7588. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  7589.  
  7590.  
  7591.  
  7592.  
  7593.  
  7594. SMB Protocol Extensions   - 116 -           November 7, 1988
  7595.  
  7596.  
  7597. 9.2.21.  WRITE and X
  7598.  
  7599. Request Format:
  7600.  
  7601.   BYTE   smb_wct;         /* value = 12 */
  7602.   BYTE   smb_com2;        /* secondary (X) command, 0xFF = none */
  7603.   BYTE   smb_reh2;        /* reserved (must be zero) */
  7604.   WORD   smb_off2;        /* offset (from SMB hdr start) to next cmd (@smb_wct) */
  7605.   WORD   smb_fid;         /* file handle */
  7606.  DWORD   smb_offset;      /* offset in file to begin write */
  7607.  DWORD   smb_timeout;     /* number of milliseconds to wait for completion */
  7608.   WORD   smb_wmode;       /* write mode:
  7609.                           bit0 - complete write before return (write through)
  7610.                           bit1 - return smb_remaining (pipes/devices only)
  7611.                           bit2 - use WriteRawNamedPipe (pipes only)
  7612.                           bit3 - this is the start of a message (pipes only) */
  7613.   WORD   smb_countleft;   /* bytes remaining to write to satisfy user's request */
  7614.   WORD   smb_rsvd;        /* reserved */
  7615.   WORD   smb_dsize;       /* number of data bytes in buffer (min value = 0) */
  7616.   WORD   smb_doff;        /* offset (from start of SMB hdr) to data bytes */
  7617.   WORD   smb_bcc;         /* total bytes (including pad bytes) following */
  7618.   BYTE   smb_pad[];       /* (optional) to pad to word or dword boundary */
  7619.   BYTE   smb_data[*];     /* data bytes (* = value of smb_dsize) */
  7620.  
  7621.  
  7622.  
  7623. Response Format:
  7624.  
  7625.   BYTE   smb_wct;         /* value = 6 */
  7626.   BYTE   smb_com2;        /* secondary (X) command, 0xFF = none */
  7627.   BYTE   smb_res2;        /* reserved (pad to word) */
  7628.   WORD   smb_off2;        /* offset (from SMB hdr start) to next cmd (@smb_wct) */
  7629.   WORD   smb_count;       /* number of bytes written */
  7630.   WORD   smb_remaining;   /* bytes remaining to be read (pipes/devices only) */
  7631.  DWORD   smb_rsvd;        /* reserved */
  7632.   WORD   smb_bcc;         /* value = 0 */
  7633.  
  7634.  
  7635. Service:
  7636.  
  7637. The expanded write and X command allows writes to  be  timed
  7638. out,  and offers a generalized alternative to the core write
  7639. command.
  7640.  
  7641. Note that a zero length write (smb_count = 0) does NOT trun-
  7642. cate the file as is true of the core write protocol.  Rather
  7643. a zero length write merely transfers zero bytes of  informa-
  7644. tion  to  the  file  (times  associated with the file may be
  7645. updated however).  The the core  "Write"  protocol  must  be
  7646. used to truncate the file.
  7647.  
  7648. The entire message sent and received including the  optional
  7649. second  protocol  must  fit  in  the negotiated max transfer
  7650. size.
  7651.  
  7652.  
  7653.  
  7654. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  7655.  
  7656.  
  7657.  
  7658.  
  7659.  
  7660. SMB Protocol Extensions   - 117 -           November 7, 1988
  7661.  
  7662.  
  7663. The following are the only valid protocol requests  commands
  7664. for smb_com2 (X) for WRITE and X:
  7665.  
  7666.         READ
  7667.         READ and X
  7668.         LOCKING and X
  7669.         LOCKREAD
  7670.         CLOSE
  7671.         CLOSE and DISCONNECT
  7672.  
  7673. When the smb_timeout field is  non-zero,  it  specifies  the
  7674. maximum milliseconds the server is to wait for a response to
  7675. its write command.  This feature is  useful  when  accessing
  7676. remote  devices,  such  as  terminals,  where  indeterminate
  7677. delays are possible (e.g. control-S active).
  7678.  
  7679. Zero in the smb_timeout field indicates that no blocking  is
  7680. desired.   The server should write only as many bytes to the
  7681. pipe or device as  will  be  accepted  without  causing  any
  7682. delay.
  7683.  
  7684. A negative 2 smb_timeout value  indicates  that  the  server
  7685. should  use  the  default  timeout value associated with the
  7686. pipe or device being written.  Thus no timeout is explicitly
  7687. set  to  the resource, rather the current timeout set either
  7688. as a default or as a result of an IOCTL remains in effect.
  7689.  
  7690. A negative 1 value in the smb_timeout field  indicates  that
  7691. the  server  should block (or loop) writing all the data (or
  7692. error) before returning.  Thus the server should  try  "for-
  7693. ever" to get the data to the resource.
  7694.  
  7695. The Write command's scope is extended to Named  Pipes,  com-
  7696. munication  devices, printer devices and spooled output (can
  7697. be used in place of "Write Print File").
  7698.  
  7699. The server should  "spin"  here  writing  all  date  to  the
  7700. file/pipe/device  if the write is followed by a close proto-
  7701. col (the "X" of WriteAndX present in the same request  is  a
  7702. close).
  7703.  
  7704. The return field smb_remaining is to be returned  for  pipes
  7705. or  devices  only.  It is used to return the number of bytes
  7706. currently available in the pipe or device. This  information
  7707. can  then  be used by the consumer to know when a subsequent
  7708. (non blocking) read of the pipe or device  may  return  some
  7709. data.   Note  -  that  when  the  read  request  is actually
  7710. received by the server there may be more or less actual data
  7711. in  the  pipe  or  device (more data has been written to the
  7712. pipe / device or another reader drained it).  If the  infor-
  7713. mation  is currently not available or the request is NOT for
  7714. a pipe or device  (or  the  server  does  not  support  this
  7715. feature), a -1 value should be returned.
  7716.  
  7717.  
  7718.  
  7719.  
  7720. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  7721.  
  7722.  
  7723.  
  7724.  
  7725.  
  7726. SMB Protocol Extensions   - 118 -           November 7, 1988
  7727.  
  7728.  
  7729. Write and X may generate the following errors:
  7730.  
  7731.         Error Class ERRDOS:
  7732.  
  7733.           ERRnoaccess
  7734.           ERRbadfid
  7735.           ERRlock
  7736.           ERRbadfiletype
  7737.           ERRbadaccess
  7738.  
  7739.  
  7740.         Error Class ERRSRV:
  7741.  
  7742.           ERRerror
  7743.           ERRinvnid
  7744.           ERRtimeout
  7745.           <implementation specific>
  7746.  
  7747.  
  7748.         Error Class ERRHRD:
  7749.  
  7750.           <implementation specific>
  7751.  
  7752.  
  7753.  
  7754.  
  7755.  
  7756.  
  7757.  
  7758.  
  7759.  
  7760.  
  7761.  
  7762.  
  7763.  
  7764.  
  7765.  
  7766.  
  7767.  
  7768.  
  7769.  
  7770.  
  7771.  
  7772.  
  7773.  
  7774.  
  7775.  
  7776.  
  7777.  
  7778.  
  7779.  
  7780.  
  7781.  
  7782.  
  7783.  
  7784.  
  7785.  
  7786. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  7787.  
  7788.  
  7789.  
  7790.  
  7791.  
  7792. SMB Protocol Extensions   - 119 -           November 7, 1988
  7793.  
  7794.  
  7795. 9.2.22.  WRITE BLOCK MULTIPLEXED
  7796.  
  7797. Primary Request Format:  (smb_com = SMBwriteBmpx)
  7798.  
  7799.   BYTE   smb_wct;       /* value = 12 */
  7800.   WORD   smb_fid;       /* file handle */
  7801.   WORD   smb_tcount;    /* total bytes (including this buf, 65,535 max) */
  7802.   WORD   smb_rsvd;      /* reserved */
  7803.  DWORD   smb_offset;    /* offset in file to begin write */
  7804.  DWORD   smb_timeout;   /* number of milliseconds to wait for completion */
  7805.   WORD   smb_wmode;     /* write mode:
  7806.                         bit0 - complete write to disk and send final result response
  7807.                         bit1 - return smb_remaining (pipes/devices only) */
  7808.  DWORD   smb_rsvd2;     /* reserved */
  7809.   WORD   smb_dsize;     /* number of data bytes this buffer (min value = 0) */
  7810.   WORD   smb_doff;      /* offset (from start of SMB hdr) to data bytes */
  7811.   WORD   smb_bcc;       /* total bytes (including pad bytes) following */
  7812.   BYTE   smb_pad[];     /* (optional) to pad to word or dword boundary */
  7813.   BYTE   smb_data[*];   /* data bytes (* = value of smb_dsize) */
  7814.  
  7815.  
  7816.  
  7817. First Response Format (ok send remaining data):  (smb_com  =
  7818. SMBwriteBmpx)
  7819.  
  7820.   BYTE   smb_wct;         /* value = 1 */
  7821.   WORD   smb_remaining;   /* bytes remaining to be read (pipes/devices only) */
  7822.   WORD   smb_bcc;         /* value = 0 */
  7823.  
  7824.  
  7825.  
  7826. Secondary Request Format (more data) (zero to n of these):
  7827.  
  7828.   BYTE   smb_wct;       /* value = 8 */
  7829.   WORD   smb_fid;       /* file handle */
  7830.   WORD   smb_tcount;    /* total bytes to be sent this protocol */
  7831.  DWORD   smb_offset;    /* offset in file to begin write */
  7832.  DWORD   smb_rsvd;      /* reserved */
  7833.   WORD   smb_dsize;     /* number of data bytes this buffer (min value = 0) */
  7834.   WORD   smb_doff;      /* offset (from start of SMB hdr) to data bytes */
  7835.   WORD   smb_bcc;       /* total bytes (including pad bytes) following */
  7836.   BYTE   smb_pad[];     /* (optional) to pad to word or dword boundary */
  7837.   BYTE   smb_data[*];   /* data bytes (* = value of smb_dsize) */
  7838.  
  7839.  
  7840.  
  7841. Final Response Format (write through or error):  (smb_com  =
  7842. SMBwriteC)
  7843.  
  7844.   BYTE   smb_wct;     /* value = 1 */
  7845.   WORD   smb_count;   /* total number of bytes written */
  7846.   WORD   smb_bcc;     /* value = 0 */
  7847.  
  7848.  
  7849.  
  7850.  
  7851.  
  7852. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  7853.  
  7854.  
  7855.  
  7856.  
  7857.  
  7858. SMB Protocol Extensions   - 120 -           November 7, 1988
  7859.  
  7860.  
  7861. Service:
  7862.  
  7863. The Write Block Multiplexed protocol is used to maximize the
  7864. performance of writing a large block of data from the consu-
  7865. mer to the server on a multiplexed VC.
  7866.  
  7867. The Write Block Multiplexed command's scope includes (but is
  7868. not  limited  to) files, Named Pipes, communication devices,
  7869. printer devices and spooled output (can be used in place  of
  7870. "Write Print File").
  7871.  
  7872. Note that the first response format  will  be  that  of  the
  7873. final response (SMBwriteC) in the case where the server gets
  7874. an error  while  writeing  the  data  sent  along  with  the
  7875. request.   Thus  the word parameter is smb_count (the number
  7876. of bytes which  did  get  written)  any  time  an  error  is
  7877. returned.   If  an error occurs AFTER the first response has
  7878. been sent allowing the consumer to send the remaining  data,
  7879. the  final  response should NOT be sent unless write through
  7880. is set.  Rather the server should return this "write behind"
  7881. error on the next access to the file/pipe/device.
  7882.  
  7883. When this protocol is used, other requests may be active  on
  7884. the  multiplexed  VC.   The  server  will  respond  with the
  7885. response protocol message as defined  above.   The  consumer
  7886. will  then  send  a  sequence  of "Secondary Write" protocol
  7887. requests until the  remaining  data  amount  has  been  sent
  7888. (unless  all data fit within primary request).  Each request
  7889. contains the smb_pid of the original Write Block Multiplexed
  7890. request,  the  file  offset  and  data length defined in the
  7891. Write response protocol (including the  SMB  header).   This
  7892. allows  the  server's message delivery (multiplexing) system
  7893. to deliver the response to the appropriate server process.
  7894.  
  7895. At the time of the request, the consumer knows the number of
  7896. data  bytes  expected to be sent and passes this information
  7897. to the server via the primary request (smb_tcount). This may
  7898. be  reduced  by  lowering the total number of bytes expected
  7899. (smb_tcount) in each (any) secondary request.
  7900.  
  7901. Thus, when the amount of data bytes received by  the  server
  7902. (total  of  each  smb_dsize) equals the total amount of data
  7903. bytes expected  (smallest  smb_tcount  received),  then  the
  7904. server has received all the data bytes. This allows the pro-
  7905. tocol to work even if the "packets" (buffers)  are  received
  7906. out of sequence.
  7907.  
  7908. This protocol eliminates nearly half the protocols  involved
  7909. with  writing  a  block of data since the Write Block Multi-
  7910. plexed response is sent only once as opposed to  each  nego-
  7911. tiated buffer size as defined with the Write protocol.
  7912.  
  7913. When write through is not specified (smb_wmode  zero),  this
  7914. protocol  is  assumed  to  be  a  form of write behind.  The
  7915.  
  7916.  
  7917.  
  7918. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  7919.  
  7920.  
  7921.  
  7922.  
  7923.  
  7924. SMB Protocol Extensions   - 121 -           November 7, 1988
  7925.  
  7926.  
  7927. transport  layer  guarantees  delivery  of   all   secondary
  7928. requests from the consumer.  Thus no "got the data you sent"
  7929. protocol is needed.  If an error should occur at the  server
  7930. end, all bytes must be received and thrown away. If an error
  7931. occurs while writing data to disk such  as  disk  full,  the
  7932. next  access of the file handle (another write, close, read,
  7933. etc.) will return the fact that the error occurred.
  7934.  
  7935. If write through is specified (smb_wmode  set),  the  server
  7936. will  collect all the data, write it to disk and then send a
  7937. final response indicating the result of the write (no  error
  7938. in  smb_err indicates data is on disk ok).  The total number
  7939. of bytes written is also returned in this response.
  7940.  
  7941. The flow for the Write Block Multiplexed  (W.B.M.)  protocol
  7942. is:
  7943.  
  7944.      cons> WRITE BLOCK MULTIPLEXED request (dat> server
  7945.      consumer <--< OK send remaining data <----  server
  7946.      consum> W. B. M. secondary request 1 (data> server
  7947.      consum> W. B. M. secondary request 2 (data> server
  7948.      .                       .                        .
  7949.      consum> W. B. M. secondary request n (data> server
  7950.      co< data on disk or error (write through onlserver
  7951.  
  7952.  
  7953. Note - if all the data being sent fits in the first  request
  7954. buffer, the primary response will still be sent, followed by
  7955. the final response after the data is actually  on  disk  (if
  7956. write  through  is  set).  This is done in order to simplify
  7957. the implementation of  this  protocol.   When  writing  data
  7958. which  all  fits within a negotiated buffer size, the "Write
  7959. and X" protocol may be a better choice.
  7960.  
  7961.  
  7962. Note that the primary request  through  the  final  response
  7963. make  up  the  complete protocol, thus the TID, PID, UID and
  7964. MID are expected to remain constant and can be used by  both
  7965. the  server and consumer to route the individual messages of
  7966. the protocol to the correct process.
  7967.  
  7968. The return field smb_remaining is to be returned  for  pipes
  7969. or  devices  only.  It is used to return the number of bytes
  7970. currently available in the pipe or device. This  information
  7971. can  then  be used by the consumer to know when a subsequent
  7972. (non blocking) read of the pipe or device  may  return  some
  7973. data.   Note  -  that  when  the  read  request  is actually
  7974. received by the server there may be more or less actual data
  7975. in  the  pipe  or  device (more data has been written to the
  7976. pipe / device or another reader drained it).  If the  infor-
  7977. mation  is currently not available or the request is NOT for
  7978. a pipe or device  (or  the  server  does  not  support  this
  7979. feature), a -1 value should be returned.
  7980.  
  7981.  
  7982.  
  7983.  
  7984. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  7985.  
  7986.  
  7987.  
  7988.  
  7989.  
  7990. SMB Protocol Extensions   - 122 -           November 7, 1988
  7991.  
  7992.  
  7993. Write Block Multiplexed may generate the  following  errors.
  7994. Note  that  the  error  ERRnoresource  (or ERRusestd) may be
  7995. returned by the server if it is  temporarily  out  of  large
  7996. buffers.   The  consumer could then retry using the standard
  7997. "core" write request, or delay and retry the read block mul-
  7998. tiplexed request.
  7999.  
  8000.         Error Class ERRDOS
  8001.  
  8002.           ERRbadfid
  8003.           ERRnoaccess
  8004.           ERRlock
  8005.           ERRbadfiletype
  8006.           ERRbadaccess
  8007.           <implementation specific>
  8008.  
  8009.  
  8010.         Error Class ERRSRV
  8011.  
  8012.           ERRerror
  8013.           ERRinvnid
  8014.           ERRnoresource
  8015.           ERRusestd
  8016.           ERRtimeout
  8017.           <implementation specific>
  8018.  
  8019.  
  8020.         Error Class ERRHRD
  8021.  
  8022.           <implementation specific>
  8023.  
  8024.  
  8025.  
  8026.  
  8027.  
  8028.  
  8029.  
  8030.  
  8031.  
  8032.  
  8033.  
  8034.  
  8035.  
  8036.  
  8037.  
  8038.  
  8039.  
  8040.  
  8041.  
  8042.  
  8043.  
  8044.  
  8045.  
  8046.  
  8047.  
  8048.  
  8049.  
  8050. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  8051.  
  8052.  
  8053.  
  8054.  
  8055.  
  8056. SMB Protocol Extensions   - 123 -           November 7, 1988
  8057.  
  8058.  
  8059. 9.2.23.  WRITE BLOCK RAW
  8060.  
  8061. Primary Request Format:  (smb_com = SMBwriteBraw)
  8062.  
  8063.   BYTE   smb_wct;       /* value = 12 */
  8064.   WORD   smb_fid;       /* file handle */
  8065.   WORD   smb_tcount;    /* total bytes (including this buf, 65,535 max ) */
  8066.   WORD   smb_rsvd;      /* reserved */
  8067.  DWORD   smb_offset;    /* offset in file to begin write */
  8068.  DWORD   smb_timeout;   /* number of milliseconds to wait for completion */
  8069.   WORD   smb_wmode;     /* write mode:
  8070.                         bit0 - complete write to disk and send final result response
  8071.                         bit1 - return smb_remaining (pipes/devices only) */
  8072.  DWORD   smb_rsvd2;     /* reserved  */
  8073.   WORD   smb_dsize;     /* number of data bytes this buffer (min value = 0) */
  8074.   WORD   smb_doff;      /* offset (from start of SMB hdr) to data bytes */
  8075.   WORD   smb_bcc;       /* total bytes (including pad bytes) following */
  8076.   BYTE   smb_pad[];     /* (optional) to pad to word or dword boundary */
  8077.   BYTE   smb_data[*];   /* data bytes (* = value of smb_dsize) */
  8078.  
  8079.  
  8080.  
  8081. First  Response  Format  (ok  send  the   remaining   data):
  8082. (smb_com = SMBwriteBraw)
  8083.  
  8084.   BYTE   smb_wct;         /* value = 1 */
  8085.   WORD   smb_remaining;   /* bytes remaining to be read (pipes/devices only) */
  8086.   WORD   smb_bcc;         /* value = 0 */
  8087.  
  8088.  
  8089.  
  8090. Secondary Request is the send of the raw data bytes:
  8091.  
  8092.  
  8093. Final Response Format (write through or error):  (smb_com  =
  8094. SMBwriteC)
  8095.  
  8096.   BYTE   smb_wct;     /* value = 1 */
  8097.   WORD   smb_count;   /* total number of bytes written */
  8098.   WORD   smb_bcc;     /* value = 0 */
  8099.  
  8100.  
  8101.  
  8102. Service:
  8103.  
  8104. The Write Block Raw protocol is used to maximize the perfor-
  8105. mance  of writing a large block of data from the consumer to
  8106. the server.
  8107.  
  8108. The Write Block Raw command's scope  includes  (but  is  not
  8109. limited  to)  files,  Named  Pipes,  communication  devices,
  8110. printer devices and spooled output (can be used in place  of
  8111. "Write Print File").
  8112.  
  8113.  
  8114.  
  8115.  
  8116. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  8117.  
  8118.  
  8119.  
  8120.  
  8121.  
  8122. SMB Protocol Extensions   - 124 -           November 7, 1988
  8123.  
  8124.  
  8125. Note that the first response format  will  be  that  of  the
  8126. final response (SMBwriteC) in the case where the server gets
  8127. an error  while  writeing  the  data  sent  along  with  the
  8128. request.   Thus  the word parameter is smb_count (the number
  8129. of bytes which  did  get  written)  any  time  an  error  is
  8130. returned.   If  an error occurs AFTER the first response has
  8131. been sent allowing the consumer to send the remaining  data,
  8132. the  final  response should NOT be sent unless write through
  8133. is set.  Rather the server should return this "write behind"
  8134. error on the next access to the file/pipe/device.
  8135.  
  8136. When this protocol is used, the consumer has guaranteed that
  8137. there  is  (and  will be) no other request on the VC for the
  8138. duration of the Write Block Raw request.   The  server  will
  8139. allocate  (or reserve) enough memory to receive the data and
  8140. respond with a response protocol message as  defined  above.
  8141. The  consumer  will then send the raw data (one send).  Thus
  8142. the server is able to receive up to  65,535  bytes  of  data
  8143. directly  into  the  server buffer.  Note that the amount of
  8144. data transferred is expected to be  larger  than  the  nego-
  8145. tiated buffer size for this protocol.
  8146.  
  8147. The reason that no other requests can be active  on  the  VC
  8148. for  the  duration  of the request is that if other receives
  8149. are present on the VC, there is normally no way to guarantee
  8150. that the data will be received into the large server buffer,
  8151. rather the data may fill one (or more) of the other buffers.
  8152. Also  if the consumer is sending other requests on the VC, a
  8153. request may land in the buffer that the server has allocated
  8154. for the Write Raw Data.
  8155.  
  8156. Support of this protocol is optional.
  8157.  
  8158. Whether or not Write Block Raw is supported is  returned  in
  8159. the  response  to  negotiate  and in the LANMAN 1.0 extended
  8160. "Query Server Information" protocol.
  8161.  
  8162. When write through is not specified (smb_wmode  zero),  this
  8163. protocol is assumed to be a form of write behind.  The tran-
  8164. sport layer guarantees delivery of  all  secondary  requests
  8165. from the consumer.  Thus no "got the data you sent" protocol
  8166. is needed.  If an error should occur at the server end,  all
  8167. bytes  must  be received and thrown away. If an error occurs
  8168. while writing data to disk  such  as  disk  full,  the  next
  8169. access of the file handle (another write, close, read, etc.)
  8170. will return the fact that the error occurred.
  8171.  
  8172. If write through is specified (smb_wmode  set),  the  server
  8173. will  receive  the  data,  write  it to disk and then send a
  8174. final response indicating the result of the write (no  error
  8175. in  smb_err  indicates data is on disk ok). The total number
  8176. of bytes written is also returned in this response.
  8177.  
  8178. The flow for the Write Block Raw protocol is:
  8179.  
  8180.  
  8181.  
  8182. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  8183.  
  8184.  
  8185.  
  8186.  
  8187.  
  8188. SMB Protocol Extensions   - 125 -           November 7, 1988
  8189.  
  8190.  
  8191.      cons> WRITE BLOCK RAW request (optional da> server
  8192.      consumer <---< OK send (more) data <------  server
  8193.      consumer ----------> raw data >-----------> server
  8194.      co< data on disk or error (write through onlserver
  8195.  
  8196.  
  8197. This protocol is set  up  such  that  the  Write  Block  Raw
  8198. request  may  also  carry  data.  This is an optimization in
  8199. that up to the server's buffer size (smb_maxxmt  from  nego-
  8200. tiate  response), minus the size of the Write Block Raw pro-
  8201. tocol request, may be sent along with the request.  Thus  if
  8202. the  server  is  busy and unable to support the Raw Write of
  8203. the remaining data, the data sent along with the request has
  8204. been  delivered and need not be sent again.  The Server will
  8205. write any data sent in the Write Block Raw request (and wait
  8206. for it to be on the disk or device if write through is set),
  8207. prior to sending  the  "send  raw  data"  or  "no  resource"
  8208. response.
  8209.  
  8210. The specific  responses  error  class  ERRSRV,  error  codes
  8211. ERRusempx  and  ERRusestd,  indicate that the server is tem-
  8212. porarily out of large buffers  needed  to  support  the  Raw
  8213. Write  of  the  remaining data, but that any data sent along
  8214. with the request has been successfully written.  The  consu-
  8215. mer  should  then write the remaining data using Write Block
  8216. Multiplexed (if ERRusempx  was  returned)  or  the  standard
  8217. "core"  write  request (if ERRusestd was returned), or delay
  8218. and retry using the Write Block Raw  request.   If  a  write
  8219. error  occurs  writing the initial data, it will be returned
  8220. and the Write Raw request is implicitly denied.
  8221.  
  8222.  
  8223. Note that the primary request  through  the  final  response
  8224. make  up  the  complete protocol, thus the TID, PID, UID and
  8225. MID are expected to remain constant and can be used  by  the
  8226. consumer to route the individual messages of the protocol to
  8227. the correct process.
  8228.  
  8229. The return field smb_remaining is to be returned  for  pipes
  8230. or  devices  only.  It is used to return the number of bytes
  8231. currently available in the pipe or device. This  information
  8232. can  then  be used by the consumer to know when a subsequent
  8233. (non blocking) read of the pipe or device  may  return  some
  8234. data.   Note  -  that  when  the  read  request  is actually
  8235. received by the server there may be more or less actual data
  8236. in  the  pipe  or  device (more data has been written to the
  8237. pipe / device or another reader drained it).  If the  infor-
  8238. mation  is currently not available or the request is NOT for
  8239. a pipe or device  (or  the  server  does  not  support  this
  8240. feature), a -1 value should be returned.
  8241.  
  8242.  
  8243. Write Block Raw may generate the following errors.
  8244.  
  8245.  
  8246.  
  8247.  
  8248. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  8249.  
  8250.  
  8251.  
  8252.  
  8253.  
  8254. SMB Protocol Extensions   - 126 -           November 7, 1988
  8255.  
  8256.  
  8257.  
  8258.         Error Class ERRDOS
  8259.  
  8260.           ERRbadfid
  8261.           ERRnoaccess
  8262.           ERRlock
  8263.           ERRbadfiletype
  8264.           ERRbadaccess
  8265.           <implementation specific>
  8266.  
  8267.  
  8268.         Error Class ERRSRV
  8269.  
  8270.           ERRerror
  8271.           ERRinvnid
  8272.           ERRnoresource
  8273.           ERRtimeout
  8274.           ERRusempx
  8275.           ERRusestd
  8276.           <implementation specific>
  8277.  
  8278.  
  8279.         Error Class ERRHRD
  8280.  
  8281.           <implementation specific>
  8282.  
  8283.  
  8284.  
  8285.  
  8286.  
  8287.  
  8288.  
  8289.  
  8290.  
  8291.  
  8292.  
  8293.  
  8294.  
  8295.  
  8296.  
  8297.  
  8298.  
  8299.  
  8300.  
  8301.  
  8302.  
  8303.  
  8304.  
  8305.  
  8306.  
  8307.  
  8308.  
  8309.  
  8310.  
  8311.  
  8312.  
  8313.  
  8314. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  8315.  
  8316.  
  8317.  
  8318.  
  8319.  
  8320. SMB Protocol Extensions   - 127 -           November 7, 1988
  8321.  
  8322.  
  8323. 10.  DATA DEFINITIONS
  8324.  
  8325. 10.1.  COMMAND CODES
  8326.  
  8327. The command codes are unchanged for commands that are common
  8328. with the Core File Sharing Protocol.
  8329.  
  8330. The following values have been assigned for the "core"  pro-
  8331. tocol commands.
  8332.  
  8333. #define SMBmkdir      0x00   /* create directory */
  8334. #define SMBrmdir      0x01   /* delete directory */
  8335. #define SMBopen       0x02   /* open file */
  8336. #define SMBcreate     0x03   /* create file */
  8337. #define SMBclose      0x04   /* close file */
  8338. #define SMBflush      0x05   /* flush file */
  8339. #define SMBunlink     0x06   /* delete file */
  8340. #define SMBmv         0x07   /* rename file */
  8341. #define SMBgetatr     0x08   /* get file attributes */
  8342. #define SMBsetatr     0x09   /* set file attributes */
  8343. #define SMBread       0x0A   /* read from file */
  8344. #define SMBwrite      0x0B   /* write to file */
  8345. #define SMBlock       0x0C   /* lock byte range */
  8346. #define SMBunlock     0x0D   /* unlock byte range */
  8347. #define SMBctemp      0x0E   /* create temporary file */
  8348. #define SMBmknew      0x0F   /* make new file */
  8349. #define SMBchkpth     0x10   /* check directory path */
  8350. #define SMBexit       0x11   /* process exit */
  8351. #define SMBlseek      0x12   /* seek */
  8352. #define SMBtcon       0x70   /* tree connect */
  8353. #define SMBtdis       0x71   /* tree disconnect */
  8354. #define SMBnegprot    0x72   /* negotiate protocol */
  8355. #define SMBdskattr    0x80   /* get disk attributes */
  8356. #define SMBsearch     0x81   /* search directory */
  8357. #define SMBsplopen    0xC0   /* open print spool file */
  8358. #define SMBsplwr      0xC1   /* write to print spool file */
  8359. #define SMBsplclose   0xC2   /* close print spool file */
  8360. #define SMBsplretq    0xC3   /* return print queue */
  8361. #define SMBsends      0xD0   /* send single block message */
  8362. #define SMBsendb      0xD1   /* send broadcast message */
  8363. #define SMBfwdname    0xD2   /* forward user name */
  8364. #define SMBcancelf    0xD3   /* cancel forward */
  8365. #define SMBgetmac     0xD4   /* get machine name */
  8366. #define SMBsendstrt   0xD5   /* send start of multi-block message */
  8367. #define SMBsendend    0xD6   /* send end of multi-block message */
  8368. #define SMBsendtxt    0xD7   /* send text of multi-block message */
  8369.  
  8370.  
  8371.  
  8372.  
  8373.  
  8374.  
  8375.  
  8376.  
  8377.  
  8378.  
  8379.  
  8380. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  8381.  
  8382.  
  8383.  
  8384.  
  8385.  
  8386. SMB Protocol Extensions   - 128 -           November 7, 1988
  8387.  
  8388.  
  8389. The commands added by the LANMAN 1.0 Extended  File  Sharing
  8390. Protocol have the following command codes:
  8391.  
  8392. #define SMBlockread      0x13   /* lock then read data */
  8393. #define SMBwriteunlock   0x14   /* write then unlock data */
  8394. #define SMBreadBraw      0x1A   /* read block raw */
  8395. #define SMBreadBmpx      0x1B   /* read block multiplexed */
  8396. #define SMBreadBs        0x1C   /* read block (secondary response) */
  8397. #define SMBwriteBraw     0x1D   /* write block raw */
  8398. #define SMBwriteBmpx     0x1E   /* write block multiplexed */
  8399. #define SMBwriteBs       0x1F   /* write block (secondary request) */
  8400. #define SMBwriteC        0x20   /* write complete response */
  8401. #define SMBsetattrE      0x22   /* set file attributes expanded */
  8402. #define SMBgetattrE      0x23   /* get file attributes expanded */
  8403. #define SMBlockingX      0x24   /* lock/unlock byte ranges and X */
  8404. #define SMBtrans         0x25   /* transaction - name, bytes in/out */
  8405. #define SMBtranss        0x26   /* transaction (secondary request/response) */
  8406. #define SMBioctl         0x27   /* IOCTL */
  8407. #define SMBioctls        0x28   /* IOCTL  (secondary request/response) */
  8408. #define SMBcopy          0x29   /* copy */
  8409. #define SMBmove          0x2A   /* move */
  8410. #define SMBecho          0x2B   /* echo */
  8411. #define SMBwriteclose    0x2C   /* Write and Close */
  8412. #define SMBopenX         0x2D   /* open and X */
  8413. #define SMBreadX         0x2E   /* read and X */
  8414. #define SMBwriteX        0x2F   /* write and X */
  8415. #define SMBsesssetup     0x73   /* Session Set Up & X (including User Logon) */
  8416. #define SMBtconX         0x75   /* tree connect and X */
  8417. #define SMBffirst        0x82   /* find first */
  8418. #define SMBfunique       0x83   /* find unique */
  8419. #define SMBfclose        0x84   /* find close */
  8420. #define SMBinvalid       0xFE   /* invalid command */
  8421.  
  8422.  
  8423.  
  8424.  
  8425.  
  8426.  
  8427.  
  8428.  
  8429.  
  8430.  
  8431.  
  8432.  
  8433.  
  8434.  
  8435.  
  8436.  
  8437.  
  8438.  
  8439.  
  8440.  
  8441.  
  8442.  
  8443.  
  8444.  
  8445.  
  8446. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  8447.  
  8448.  
  8449.  
  8450.  
  8451.  
  8452. SMB Protocol Extensions   - 129 -           November 7, 1988
  8453.  
  8454.  
  8455. 10.2.  ERROR CLASSES AND CODES
  8456.  
  8457. The error class and code lists in the  section  include  all
  8458. classes  and codes generated by the Core File Sharing Proto-
  8459. col. Errors listed here are  intended  to  provide  a  finer
  8460. granularity  of  error conditions.  These lists are not com-
  8461. plete.
  8462.  
  8463. The following error classes may be returned by the  protocol
  8464. elements defined in this document.
  8465.  
  8466. SUCCESS      0   The request was successful.
  8467. ERRDOS    0x01   Error is from the core DOS operating system set.
  8468. ERRSRV    0x02   Error is generated by the server network file manager.
  8469. ERRHRD    0x03   Error is an hardware error.
  8470. ERRXOS    0x04   Reserved for XENIX.
  8471. ERRRMX1   0xE1   Reserved for iRMX
  8472. ERRRMX2   0xE2   Reserved for iRMX
  8473. ERRRMX3   0xE3   Reserved for iRMX
  8474. ERRCMD    0xFF   Command was not in the "SMB" format.
  8475.  
  8476.  
  8477. The following error codes may be generated with the  SUCCESS
  8478. error class.
  8479.  
  8480. SUCCESS   0   The request was successful.
  8481.  
  8482.  
  8483. The following error codes may be generated with  the  ERRDOS
  8484. error  class.   The XENIX errors equivalent to each of these
  8485. errors are noted at the end of the error description.   NOTE
  8486. -  When  the  extended  protocol (LANMAN 1.0) has been nego-
  8487. tiated, all of the error codes below may be  generated  plus
  8488. any  of  the  new  error  codes  defined  for OS/2 (see OS/2
  8489. operating system documentation for  complete  list  of  OS/2
  8490. error  codes).   When  only  "core"  protocol has been nego-
  8491. tiated, the server must map additional OS/2 (or  OS/2  like)
  8492. errors to the errors listed below.
  8493.  
  8494.  
  8495.  
  8496.  
  8497.  
  8498.  
  8499.  
  8500.  
  8501.  
  8502.  
  8503.  
  8504.  
  8505.  
  8506.  
  8507.  
  8508.  
  8509.  
  8510.  
  8511.  
  8512. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  8513.  
  8514.  
  8515.  
  8516.  
  8517.  
  8518. SMB Protocol Extensions   - 130 -           November 7, 1988
  8519.  
  8520.  
  8521. The following error codes may be generated with  the  ERRDOS
  8522. error class.
  8523.  
  8524. ERRbadfunc          1
  8525.                         Invalid function.  The server OS did not recognize or could not  perform
  8526.                         a system call generated by the server, e.g., set the DIRECTORY attribute
  8527.                         on a data file, invalid seek mode. [EINVAL]
  8528. ERRbadfile          2
  8529.                         File not found.  The last component of a file's pathname  could  not  be
  8530.                         found.  [ENOENT]
  8531. ERRbadpath          3
  8532.                         Directory invalid.  A directory component in a  pathname  could  not  be
  8533.                         found.  [ENOENT]
  8534. ERRnofids           4
  8535.                         Too many open files.  The server has no file handles  (FIDs)  available.
  8536.                         [EMFILE]
  8537. ERRnoaccess         5
  8538.                         Access denied, the requester's context does  not  permit  the  requested
  8539.                         function.  This includes the following conditions.  [EPERM]
  8540.                             invalid rename command
  8541.                             write to fid open for read only
  8542.                             read on fid open for write only
  8543.                             Attempt to delete a non-empty directory
  8544. ERRbadfid           6
  8545.                         Invalid file handle.  The file handle specified was  not  recognized  by
  8546.                         the server.  [EBADF]
  8547. ERRbadmcb           7   Memory control blocks destroyed.  [EREMOTEIO]
  8548. ERRnomem            8   Insufficient server memory to perform the requested function.  [ENOMEM]
  8549. ERRbadmem           9   Invalid memory block address.  [EFAULT]
  8550. ERRbadenv          10   Invalid environment.  [EREMOTEIO]
  8551. ERRbadformat       11   Invalid format.  [EREMOTEIO]
  8552. ERRbadaccess       12   Invalid open mode.
  8553. ERRbaddata         13   Invalid data (generated only by IOCTL calls within the server).  [E2BIG]
  8554. ERR                14   reserved
  8555. ERRbaddrive        15   Invalid drive specified.  [ENXIO]
  8556. ERRremcd           16
  8557.                         A Delete Directory request attempted  to  remove  the  server's  current
  8558.                         directory.  [EREMOTEIO]
  8559. ERRdiffdevice      17   Not same device (e.g., a cross volume rename was attempted)  [EXDEV]
  8560. ERRnofiles         18
  8561.                         A File Search command can find no more files matching the specified cri-
  8562.                         teria.
  8563. ERRbadshare        32
  8564.                         The sharing mode specified for an Open conflicts with existing  FIDs  on
  8565.                         the file.  [ETXTBSY]
  8566. ERRlock            33
  8567.                         A Lock request conflicted with an existing lock or specified an  invalid
  8568.                         mode,  or an Unlock requested attempted to remove a lock held by another
  8569.                         process.  [EDEADLOCK]
  8570. ERRfilexists       80
  8571.                         The file named in a Create Directory, Make  New  File  or  Link  request
  8572.                         already exists. The error may also be generated in the Create and Rename
  8573.                         transaction.  [EEXIST]
  8574.  
  8575. ERRbadpipe        230   Pipe invalid.
  8576. ERRpipebusy       231   All instances of the requested pipe are busy.
  8577. ERRpipeclosing    232   Pipe close in progress.
  8578. ERRnotconnected   233   No process on other end of pipe.
  8579. ERRmoredata       234   There is more data to be returned.
  8580.  
  8581.  
  8582.  
  8583.  
  8584.  
  8585.  
  8586.  
  8587.  
  8588. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  8589.  
  8590.  
  8591.  
  8592.  
  8593.  
  8594. SMB Protocol Extensions   - 131 -           November 7, 1988
  8595.  
  8596.  
  8597. The following error codes may be generated with  the  ERRSRV
  8598. error class.
  8599.  
  8600. ERRerror              1   Non-specific error code.  It is returned under the following conditions:
  8601.                               resource other than disk space exhausted (e.g. TIDs)
  8602.                               first command on VC was not negotiate
  8603.                               multiple negotiates attempted
  8604.                               internal server error [ENFILE]
  8605. ERRbadpw              2
  8606.                           Bad password - name/password pair in a Tree Connect or Session Setup are
  8607.                           invalid.
  8608. ERRbadtype            3   reserved
  8609. ERRaccess             4
  8610.                           The requester does not have  the  necessary  access  rights  within  the
  8611.                           specified  context for the requested function. The context is defined by
  8612.                           the TID or the UID.  [EACCES]
  8613. ERRinvnid             5   The tree ID (TID) specified in a command was invalid.
  8614. ERRinvnetname         6   Invalid network name in tree connect.
  8615. ERRinvdevice          7
  8616.                           Invalid device - printer request made to non-printer connection or  non-
  8617.                           printer request made to printer connection.
  8618. ERRqfull             49   Print queue full (files) -- returned by open print file.
  8619. ERRqtoobig           50   Print queue full -- no space.
  8620. ERRqeof              51   EOF on print queue dump.
  8621. ERRinvpfid           52   Invalid print file FID.
  8622. ERRsmbcmd            64   The server did not recognize the command received.
  8623. ERRsrverror          65
  8624.                           The server encountered an internal error, e.g., system file unavailable.
  8625. ERRfilespecs         67
  8626.                           The file handle (FID) and pathname parameters contained an invalid  com-
  8627.                           bination of values.
  8628. ERRreserved          68   reserved.
  8629. ERRbadpermits        69
  8630.                           The access permissions specified for a file or directory are not a valid
  8631.                           combination.  The server cannot set the requested attribute.
  8632. ERRreserved          70   reserved.
  8633. ERRsetattrmode       71   The attribute mode in the Set File Attribute request is invalid.
  8634. ERRpaused            81   Server is paused. (reserved for messaging)
  8635. ERRmsgoff            82   Not receiving messages. (reserved for messaging).
  8636. ERRnoroom            83   No room to buffer message. (reserved for messaging).
  8637. ERRrmuns             87   Too many remote user names. (reserved for messaging).
  8638. ERRtimeout           88   Operation timed out.
  8639. ERRnoresource        89   No resources currently available for request.
  8640. ERRtoomanyuids       90   Too many UIDs active on this session.
  8641. ERRbaduid            91   The UID is not known as a valid ID on this session.
  8642.  
  8643. ERRusempx           250   Temp unable to support Raw, use MPX mode.
  8644. ERRusestd           251   Temp unable to support Raw, use standard read/write.
  8645. ERRcontmpx          252   Continue in MPX mode.
  8646. ERRreserved         253   reserved.
  8647. ERRreserved         254   reserved.
  8648.  
  8649. ERRnosupport     0xFFFF   Function not supported.
  8650.  
  8651.  
  8652.  
  8653.  
  8654.  
  8655.  
  8656.  
  8657.  
  8658.  
  8659. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  8660.  
  8661.  
  8662.  
  8663.  
  8664.  
  8665. SMB Protocol Extensions   - 132 -           November 7, 1988
  8666.  
  8667.  
  8668. The following error codes may be generated with  the  ERRHRD
  8669. error  class.   The XENIX errors equivalent to each of these
  8670. errors are noted at the end of the error description.
  8671.  
  8672. ERRnowrite       19   Attempt to write on write-protected diskette.  [EROFS]
  8673. ERRbadunit       20   Unknown unit.  [ENODEV]
  8674. ERRnotready      21   Drive not ready.  [EUCLEAN]
  8675. ERRbadcmd        22   Unknown command.
  8676. ERRdata          23   Data error (CRC).  [EIO]
  8677. ERRbadreq        24   Bad request structure length.  [ERANGE]
  8678. ERRseek          25   Seek error.
  8679. ERRbadmedia      26   Unknown media type.
  8680. ERRbadsector     27   Sector not found.
  8681. ERRnopaper       28   Printer out of paper.
  8682. ERRwrite         29   Write fault.
  8683. ERRread          30   Read fault.
  8684. ERRgeneral       31   General failure.
  8685. ERRbadshare      32   A open conflicts with an existing open. [ETXTBSY]
  8686. ERRlock          33
  8687.                       A Lock request conflicted with  an  existing  lock  or
  8688.                       specified  an  invalid  mode,  or  an Unlock requested
  8689.                       attempted to remove a lock held  by  another  process.
  8690.                       [EDEADLOCK]
  8691. ERRwrongdisk     34
  8692.                       The wrong disk was found in a drive.
  8693. ERRFCBUnavail    35
  8694.                       No FCBs are available to process request.
  8695. ERRsharebufexc   36
  8696.                       A sharing buffer has been exceeded.
  8697.  
  8698.  
  8699.  
  8700.  
  8701.  
  8702.  
  8703.  
  8704.  
  8705.  
  8706.  
  8707.  
  8708.  
  8709.  
  8710.  
  8711.  
  8712.  
  8713.  
  8714.  
  8715.  
  8716.  
  8717.  
  8718.  
  8719.  
  8720.  
  8721.  
  8722.  
  8723.  
  8724.  
  8725.  
  8726.  
  8727.  
  8728.  
  8729. Copyright Microsoft Corporation, 1987, 198Microsoft Networks
  8730.  
  8731.  
  8732.